Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multilanguage Support via gettext #1

Closed
gautiermichelin opened this issue Aug 12, 2013 · 10 comments
Closed

Multilanguage Support via gettext #1

gautiermichelin opened this issue Aug 12, 2013 · 10 comments

Comments

@gautiermichelin
Copy link

See https://github.com/thane-de-loth/osTicket-1.7/commit/40a89ee3eac92ed28bc9853c742908b4575883e2
and osTicket/osTicket-1.7#509

Need to check and compare with @thane-de-loth pull request :

  • add gettext encapsulations to all texts (need a go from @greezybacon to select only files that won't change much first)
  • add fallback function for the case that the gettext extension isn't loaded
  • add gettext to the list of optional extensions in setup
  • rewrite some of the texts to use sprintf instead of appending strings

This issue is meant to prepare for i18n, not starting translation, which comes after.

@sabas
Copy link
Contributor

sabas commented Aug 23, 2013

Take a look at https://github.com/sabas/msgfmtPHP , you shouldn't use directly gettext because Apache caches translations. Also see the approach from Wordpress (which I couldn't use due to license conflict).

@belzael
Copy link
Contributor

belzael commented Sep 7, 2013

I'd be happy to help. I'm just not very experienced with PHP and github, so don't expect a lot from me. Especially no elegant solutions. :)

@gautiermichelin
Regarding your first and second Point. I think using a wrapper function and pointing it to a fallback function (I let it echo the text) would be a good way.
Also i agree with greezybacon and tomashastings that we have to clean up the content. For example: all the msg errors and warn variables in the /scp/*.php files are essentially the same with one or two different words.

@sabas
Speaking from my short experience with gettext here.
I don't think the caching is an issue in the end product. It just hinders the translations. The bigger issue with using the extension are the other restrictions like missing locales or being a pain to set up. Especially if you actually want to use multiple languages in the same context. That's why i've used a parser similar to yours, though it has its own issues. I leave it up to greezybacon to decide if a parser is necessary or not.

@talas9
Copy link

talas9 commented Sep 14, 2013

I Have An arabic translated copy of 1.7.0 and I can help (translate/add language engine) the latest copy

@t-oster
Copy link
Contributor

t-oster commented Oct 14, 2013

Hi. In my projects, I personally just create a globally visible function called "t", which handles the translation. The arguments are similar to printf, so you get either a string, or a string containing variables like "%s", "%i" etc and the arguments.
Then in the implementation of "t" you can easily switch the translation engine to everything you want. In the simplest case, just call printf with the original string.

I suppose you create one additional "translation.php" which introduces this function and change all code to just "require_once" this file and use the function. Using "t" as name has also the advantage, that there is not much to write. I'd use the english version as "key", so the code stays readable and if some translations are missing, just the english version is printed.

@t-oster
Copy link
Contributor

t-oster commented Oct 15, 2013

If you like my idea, please clone my "feature-generic-translation" branch, copy the "include/i18n/en_US" folder to your locale and translate the file "include/i18n/xx_XX/lang.php". Currently only the guest login-page is translated, but feel free to update other templates in "include/client" as I did in the commit. Basically just change "Text to be translated" to "". That's it. now you can add to your "lang.php":

"Text to be translated" => "your translation"

@kmmoreau kmmoreau mentioned this issue Nov 12, 2013
@ghost ghost mentioned this issue Mar 3, 2014
@ismannen ismannen mentioned this issue Mar 19, 2014
@greezybacon
Copy link
Contributor

This is finally implemented in #1096 and slated for osTicket 1.9.3. Thanks again for everyone's help making this a reality

@ntozier
Copy link
Contributor

ntozier commented Jul 7, 2014

Safe to presume that you meant 2.10?

JediKev added a commit that referenced this issue Apr 19, 2022
This addresses an issue reported on the Forum where when adding a new Queue
Sort an error of `Uncaught TypeError: count(): Argument #1 ($value) must be
of type Countable|array, string given` is thrown. This is due to passing the
wrong arguments to the `QueueSort::update()` method. This corrects the
arguments to `$vars, $errors` to resolve the error.
JensEB added a commit to JensEB/osTicket that referenced this issue Feb 3, 2023
…lude/class.session.php:314

To prevent following error:
PHP Fatal error: Uncaught Error: Call to a member function getId() on bool in /.../include/class.session.php:314

Logged back trace:

PHP Fatal error: Uncaught Error: Call to a member function getId() on bool in /.../include/class.session.php:314
Stack trace:
#0 /.../include/class.session.php(336): osTicket\\Session\\AbstractSessionStorageBackend->getRecord()
osTicket#1 /.../include/class.session.php(281): osTicket\\Session\\AbstractSessionStorageBackend->update()
osTicket#2 [internal function]: osTicket\\Session\\AbstractSessionHandler->write()
osTicket#3 [internal function]: session_write_close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants