Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

osTicket v1.10 (stable) and Maintenance Release v1.9.15 are now available! Go get it now

[MOD] Multilanguage Support

edited November 2013 in Mods and Customizations
I had to translate osTicket 1.7 to german since the company I am employed at plans to use it. To make translation easy and adaptable for future updates i used gettext. Since i already had to do the work, i thought i should share it.

My modifications are:
- Pretty much every text in the .php files is encapsulated in the short version of the gettext function ('__()').
- Added a central configuration file for the translation settings
- Added a fallback function, for the case, that the gettext extension isn't loaded
- Simplified some of the texts by using sprintf
- Added language detection based on browser preferences (thanks to Darrin Yeager)
- Included php_gettext (since RC6_V5)
- The german translation file

Now to the interesting stuff:
Which version of osTicket was modded:
osTicket 1.7 RC6
osTicket 1.7 Stable

How to use it:
Unzip it and put the folder on your webserver. In the most cases that should be it. However if multilanguage still doesn't work check if you have the mbsting extension activated. Also check your file permissions. Installing other mods will be a bit harder.

What is translated:
All of the important php files.

What is not translated:
The email-templates (you'll have to translate them via admin panel)
Generally the sql-schema used in the setup/upgrade. I can't do that since the md5 of the sql file is checked. Changing it would break the upgrader.

What also doesnt work:
Language detection in emails. I don't really know how to do that or if it is actually possible.

Currently supported languages:
- english (is the fallback)
- german

How to set a static language:
Set the line in 'include/gettext-conf.php' that contains
$language=getDefaultLanguage();

To
$language='<your_language_code>';


How to add more languages:
You'll find a tutorial here: http://thane.dyndns.org/osticket_mod...n_tutorial.htm

NOTE: When you translate some of the texts they may not show translated in your webpage. In that case you'll probably have to restart your webserver. Gettext seems to cache its contents.
Also, you'll need time and patience (a lot of it).

Gettext:
There are two gettext based engines supported right now. Primarily a pure php based engine will be used (already included and configured, it requires the mbstring extension). The Gettext Extension is too picky with the language codes in some cases (see gettext extension), which leads to no translation at all.

Gettext extension:
You should only use the extension if you know what you are doing. Although it brings a slight performance boost it'll make maintenance of multiple languages harder.
Windows:
You have to add the gettext extension in php.ini if you want to use the multilanguage feature.
Remove the ; in the line ;extension=php_gettext.dll to enable the gettext.
You'll also have to disable php_gettext by changing
$use_php_gettext=true;
to
$use_php_gettext=false;
in 'include/gettext-conf.php'

Linux:
I don't exactly know how to configure gettext on a linux server. The following is what some sites said about configuring gettext:
Your distribution may have a PHP version with precompiled gettext. If that isn't the case you'll have to compile php with the parameter --with-gettext.
Linux users that compile PHP --with-gettext=shared should include
extension=gettext.so in your /etc/php.ini
You'll also have to disable php_gettext by changing
$use_php_gettext=true;
to
$use_php_gettext=false;
in 'include/gettext-conf.php'
If after that the translation doesn't work your webserber/os probably doesn't like the language code it gets. You can see the supported language codes by executing the following command in your terminal
locale -a


Redirecting Language Codes:
To redirect a language code to a different one, create a folder inside 'include/locale' that represents the language code you want to redirect and then create a file called 'redirect' in it. The content of 'redirect' has to be the language code it should redirect to.
Example:
You want to redirect the language code 'de-de' to the code 'de' create a folder inside 'include/locale' called 'de-de'. then create the file 'redirect' in it. the path to this redirect should now look like 'include/locale/de-de/redirect'.
Now open the redirect file you've created, type de in the first line and save it.
To see how the osTicket is translated use testlang.php. It also shows language redirections, if there are any.

NOTE: A language code can be redirected only a single time!

If you find any bugs or have any questions please tell me/post them here.

Changelogs:

whole changelog list: http://thane.dyndns.org/osticket-ml-changelog.htm

07.05.2013 (osticket_1.7-stable_multilanguage_V6):
  • Added the suggestion of olest to ease setting the encoding of translations in gettext-conf
  • Also added the untranslated string olest found

16.09.2013 (osticket_1.7.1-stable_ml_V7):
  • Ported this mod to 1.7.1.1
  • Updated German translation file (thanks to hhm, Sweeny)
  • Note: there were a few changes in texts (about 90) and the "Site Pages" were added, which can't be translated with gettext, since they reside in the database.

26.09.2013 (osticket_1.7.1.4-stable_ml_V8):
  • Ported this mod to 1.7.1.4
  • Updated German translation file
  • Note: there was another change in texts (the "Howdy,")

25.10.2013 (osticket_1.7.2-stable_ml_V9):
  • Ported this mod to 1.7.2
  • Added the changes suggested by olest

29.10.2013 (osticket_1.7.2-stable_ml_V10):
  • Added missing changed pictures and removed extra files

Downloads:
osticket_1.7.2-stable_ml_V10

Old Links (do not use those in production environments):
osticket_1.7-RC6_multilanguage
osticket_1.7-RC6_multilanguage_V2
osticket_1.7-RC6_multilanguage_V3
osticket_1.7-RC6_multilanguage_V4
osticket_1.7-RC6_multilanguage_V5
osticket_1.7-stable_multilanguage
osticket_1.7-stable_multilanguage_V2
osticket_1.7-stable_multilanguage_V3
osticket_1.7-stable_multilanguage_V4
osticket_1.7-stable_multilanguage_V5
osticket_1.7-stable_multilanguage_V6
osticket_1.7.1-stable_ml_V7
osticket_1.7.1.4-stable_ml_V8
osticket_1.7.2-stable_ml_V9
«13456710

Comments

  • Hi Thane,

    Great work on translating osticket! I'm concidering translating it to Swedish if anybody else hasn't done it already?

    Would it be possible for you to submit your changes to github and do a pull request so this could go into the mainline for osticket?

    I saw now that there is already a pull request for an i18n fork of osticket:
    https://github.com/osTicket/osTicket-1.7/pull/288
    Maybe you could check to see that you have made all the things they made? As your version is based on a later version of the code it will probably be better to use your code.
  • Hi ben,

    Great that you like my mod. I hope that it'll make translations easier for others.
    I'll try to make a pull request. I've actually only used github to clone repositorys to a local folder up till now.

    As long as it isn't in the master branch I'll try to maintain the mod, so that it stays up to date.
  • Hey

    Could set up a little "noob guide" of how to use this? I'm pretty new to osTicket..I've uploaded your build and installed it but nothing has changed. I'm using filezilla to push everything to my webserver.
    I'm kind of confused and don't want to mess your files up.
    I haven't found a php.ini in your or in the original build..
    In case it's easier for you to reply, I'm German and I'm looking for a german translation of osTicket.


    Kind regards
  • Hello DGutschalk,

    Sorry, but i can't provide the noob guide you are hoping for. It is too dependend on your server setup and configuration.

    You can't find the php.ini in the osTicket builds because the php.ini should already be on your server before you install osticket. The php.ini is the configuration file for the php-part of your webserver. To find the currently used php.ini on your server do the following:
    [LIST=1]
    [*]Create a textfile called 'info.php'
    [*]put the content <?php phpinfo(); ?> into it and save
    [*]push the file to the root directory of your webpage
    [*]open it in your webbrowser
    [/LIST]

    It will show you your current php-configuration.
    Search for the entry named 'Loaded Configuration File'.
    Here is an example:
    image

    After you've changed the php.ini you have to restart the webserver, to load your new configuration.

    You can use the info.php to see if gettext support is enabled or not. Open it in your browser again and search for gettext. If gettext is enabled you should see an entry saying: 'GetText Support enabled'

    After you've done the changes and gettext is working, you should remove the info.php from your webserver (security reasons).

    If you use a webhosting service (looks like it) or don't have access to it because of different reasons, you can use a purely php based implementation of gettext. But it is way slower than the gettext extension.

    If you still have some questions, ask away.
  • Hey

    Thanks a lot for your reply!
    Sadly I do not have permissions that deep over my webserver since I'm only renting it from a company.

    I'm trying out different ticket systems and may come back later to OSTicket
  • @DGutschalk

    Many web hosts allow people to use custom php.ini's for their website. If you check with your provider you may be able to enable this for your server. Alternatively you may be able to explain why you want to do this to your host and they may enable it for you.
  • Thane;35534 said:
    I had to translate osTicket 1.7 to german since the company I am employed at plans to use it. To make translation easy and adaptable for future updates i used gettext. Since i already had to do the work, i thought i should share it.

    My modifications are:
    - Pretty much every text in the .php files is encapsulated in the short version of the gettext function ('_()').
    - Added a central configuration file for the translation settings
    - Added a fallback function, for the case, that the gettext extension isn't loaded
    - Simplified some of the texts by using sprintf
    - Added language detection based on browser preferences (thanks to Darrin Yeager)
    - The german translation file

    Now to the interesting stuff:
    Which version of osTicket was modded:
    osTicket 1.7 RC6

    How to use it:
    Windows:
    Pretty much exactly the same as standard osTicket 1.7 RC6. You just have to add the gettext extension in php.ini if you want to use the multilanguage feature.
    Remove the ; in the line ;extension=php_gettext.dll to enable gettext.

    Linux:
    I don't exactly know how to configure gettext on a linux server. The following is what some sites said about configuring gettext:
    Your distribution may have a PHP version with precompiled gettext. If that isn't the case you'll have to compile php with the parameter --with-gettext.
    Linux users that compile PHP --with-gettext=shared should include
    extension=gettext.so in your /etc/php.ini

    What is translated:
    All of the important php files.

    What is not translated:
    The email-templates (you'll have to translate them via admin panel)
    Generally the sql-schema used in the setup/upgrade. I can't do that since the md5 of the sql file is checked. Changing it would break the upgrader.

    What also doesnt work:
    Language detection in emails. I don't really know how to do that or if it is actually possible.

    Currently supported languages:
    - english (is the standard)
    - german

    How to set a static language:
    Set the line in 'include/gettext-conf.php' that contains
    $language=getDefaultLanguage();

    To
    $language='<your_language_code>';


    How to add more languages:
    To add additional languages add a folder with your language code to 'include/locale' (for example 'de'), create the folder 'LC_MESSAGES' inside it and create your 'messages.po' file inside 'LC_MESSAGES'. With the example of de-de the full path to 'messages.po' should look like 'include/locale/de/LC_MESSAGES 'messages.po'.
    In case you don't know your language code (or to be more precise: the one your browser prefers), open the php page: 'testlang.php'.

    To translate i used the program poedit. There are other programs in case you don't like poedit (wikipedia has a list of programs, just search for gettext). If any of you want to, i can add a basic how to for poedit.

    NOTE: When you translate some of the texts they may not show translated in your webpage. In that case you'll probably have to restart your webserver. Gettext seems to cache its contents.
    Also, you'll need time and patience (a lot of it).

    If you find any bugs or have any questions please tell me/post them here.

    Updates:
    18.03.2013 (osticket_1.7-RC6_multilanguage_V2):
    • shortened the language code (e.g. 'de-de' to 'de'), since some browsers won't behave
    • added the gettext extension to the optional extensions in the setup
    • ticket-printing to pdf now also translates via gettext (don't choose too long texts, the sizes in the pdfs are static)
    • Dashboard Statistics can be translated
    • fixed a wrong translation text
    Downloadlinks:
    osticket_1.7-RC6_multilanguage
    osticket_1.7-RC6_multilanguage_V2

    Hello Thane,

    I tried out your multilanguage_V2-Version, but it don´t work. osTicktet was in english.

    So I made the language static to 'de' and it don´t work again.
    Now I made the language static to 'de_DE' and rename the folder /include/locale/de to /include/locale/de_DE and now it works fine.

    Maybe gettext need the long version "de_DE" and can´t work with "de".

    Und nun in deutsch....
    öffne die Datei /include/gettext-conf.php um die Sprache auf "nur" deutsch einzustellen.
    ersetze dann Zeile 9 von:
    $language=getDefaultLanguage();
    in
    $language='de_DE';
    und nun den Sprachordner umbenennen, damit gettext ihn findet....
    mit dem ftp-Programm folgenden Ordner umbenennen...
    /include/locale/de
    in
    /include/locale/de_DE

    nun sollte es funktionieren....

    PS: Ich habe ein deutsches Projekt zu osTicket gestartet unter: www.osTicket.com.de. Für Anregungen oder Mithelfer bin ich da offen....
  • Hello jens_E,

    Sorry about your problem with the translations. I've tested the language code detection in Firefox and Internet Explorer and both send 'de-de' for german. I didn't expect that a browser would use '_' instead of '-'. Again, sorry about that. I've fixed it, along some other things, in V3. Could you tell me the browser you've used?

    -German-

    Hallo jens_E,

    Es tut mir leid, dass Sie Probleme mit der Übersetzung hatten. Ich habe die Spracherkennung in Firefox und Internet Explorer getestet und beide haben 'de-de' gesendet. Ich hab nicht erwartet, dass ein anderer Browser '_' anstatt '-' senden würde. Nochmals Entschuldigung. Ich habe Ihr Problem und einige andere dinge, in V3 behoben. Könnten Sie mir sagen welchen Browser Sie nutzen?
  • Hi, amazing thing and awesome job! Thank you very much!
    D a n k e !! :)
  • This is awesome !!!
    Hope this gets into the master branch.
    I'm now translating into dutch :)
  • SKBR;37257 said:
    This is awesome !!!
    Hope this gets into the master branch.
    I'm now translating into dutch :)
    Did you already translated it in Dutch?
    If so can I have the translated files please? :)

    Thanks!

    Regards, Eric
  • eric111;37295 said:
    Did you already translated it in Dutch?
    If so can I have the translated files please? :)

    Thanks!

    Regards, Eric
    This should be no problem. its just one .mo file.
    The translating is taking up some extra time. a lot of phrases :)
  • Its nice to see that much interest, thanks for the feedback!
  • Vielen Dank an den Übersetzer!
  • SKBR;37257 said:
    This is awesome !!!
    Hope this gets into the master branch.
    I'm now translating into dutch :)
    How far are you? I started translating this afternoon and got to 35% before I realised somebody else might be doing the same thing.
  • Waiting for a reply took too long, I translated all 2022 strings to Dutch already. Going to upload to Github now.

    Grab the file(s) here: https://github.com/tomashastings/osTicket-1.7
  • Did anyone translate it in Italian ?
  • enrilor;37446 said:
    Did anyone translate it in Italian ?
    I only know that the fellow forum member Schwibby started translating. However, I don't know how much he translated already or if he's done.
    see http://osticket.com/forums/showthread.php?t=13730
  • Hi all

    for italian translation i've done 100% user client , but for the admin section i think i'm 50% ita and 50% german.
    if anyone want's translation and can wait one week i think i'm done.



    it is legal to create a github repo with 1.7 translated in Italian?
  • Schwibby;37511 said:

    it is legal to create a github repo with 1.7 translated in Italian?
    While it is perfectly legal to make a fork of osticket with your changes, i would prefer if you would merge your changes with my fork afterwards. I want to provide a single package with all languages instead of a lot of different packages with only one translation. Shibby is currently also trying to merge his changes with my repo. Also it makes support and potentially merging into the osticket master easier.
  • Schwibby;37511 said:
    Hi all

    for italian translation i've done 100% user client , but for the admin section i think i'm 50% ita and 50% german.
    if anyone want's translation and can wait one week i think i'm done.



    it is legal to create a github repo with 1.7 translated in Italian?
    Hi Schwibby, I'm quite busy at this time, but if you need help contact me in PM.

    Enrico
  • Thane;37485 said:
    I only know that the fellow forum member Schwibby started translating. However, I don't know how much he translated already or if he's done.
    see http://osticket.com/forums/showthread.php?t=13730
    ;) Thanks for info
  • Swedish?

    did anyone translate it to Swedish?
  • Installing other mods will be a bit harder though.

    Hello,

    thank for sharing your work, iam starting myself using osticket, i have to make several mods in the short future, ofcourse one of them is translating ( to spanish) and i wondering why Installing other mods will be a bit harder though. ?

    Thank you for your answer
    Chev
    .
  • @Chelios
    Because most mods are written out with directions like: Look for "TEXT" at line X, then add TEXT2. By utilizing a modified version of the core source, all those line number directions are now wrong. The same is also true of adding other mods. Also by removing and changing large segments of the code one will have to be choosier as to what text they send people looking for to mod.
  • ntozier;37641 said:
    @Chelios
    Because most mods are written out with directions like: Look for "TEXT" at line X, then add TEXT2. By utilizing a modified version of the core source, all those line number directions are now wrong. The same is also true of adding other mods. Also by removing and changing large segments of the code one will have to be choosier as to what text they send people looking for to mod.
    Thank you, that was a very clear answer.

    Working in my mods now, i will left to final stages the tranlations situation. I see myself hardcoding the entire clientside anyway ahah.

    Chev
    .
  • hi... faq section isn't visible in the home page... problem of mod?
  • Schwibby;37670 said:
    hi... faq section isn't visible in the home page... problem of mod?
    I've tested it and it works on my installation.

    Did you
    • Activate knowledgebase in Admin Panel
    • Add a Published Category
    • Add a FAQ to that Category
    Only if those 3 points are done it'll show up on client-side.
  • all 3 done but not appear... try to upload the file again
  • Is your osticket a fresh installation of 1.7 or did you upgrade from 1.6? There were some problems regarding the FAQ when upgrading from 1.6 (see http://osticket.com/forums/showthread.php?t=13827). If that isn't the case, set the following 2 variables in main.inc.php

        ini_set('display_errors', 0);
    ini_set('display_startup_errors', 0);


    To
        ini_set('display_errors', 1);
    ini_set('display_startup_errors', 1);


    Afterwards check if you get any errors when visiting Knowledgebase sites.

    I just did a fresh install of my osticket mod on an arm based server and the Knowledgebase worked there too. Did anyone else have such problems?
Sign In or Register to comment.