Problem with custom language

I've added a custom language to elgg by following instructions here. I'm using elgg 1.11.2.

When I switch to my custom language ("yu"), I get a 403 error for page http://127.0.0.1/cache/1455094226/default/js/languages/yu.js, as well as the following javascript error:

Error: Script error for: languages/yu 
http://requirejs.org/docs/errors.html#scripterror
 

Both things appear pretty much everywhere on my site. Everything works fine when I switch to english or the like.

All caching is disabled on my installation (since it's still in development).

  • Those instructions are almost six (!!) years old and outdated.

    Nowadays Transifex (https://www.transifex.com/elgg/elgg-core ) is being used to translate Elgg to different languages.

    1. Create an account to Transifex
    2. Request for a new language for (if one doesn't already exist)
    3. Translate the strings online
    4. The translations will be included in the next Elgg release

    (Although, note that Elgg 1.11 is receiving only security fixes, so you will have to upgrade to 1.12 in order to get the new translations.)

  • Thanks for the answer!

    If I understand this correctly, if I want to add a language to my installation of elgg, I have to first request it using Transifex, where possibly it would have to be approved by someone, and then added to next release, before I can use it?

    Normally, this would not be a problem, and I wholeheartedly support giving back to the community in such a way, however, the problem is that the language that I need to add does not actually exist, and as such, I'm not sure it would be accepted. To be precise, my client wishes to make a social networking site targeting people from ex-Yugoslavia living abroad and wants to provide a single language ("Yugoslavian") instead of separate versions (serbian, croatian, bosnian...), since these languages are completely mutally intelligible and, linguistically, are the same language.

  • Ok, your use case is indeed an exception. It is possible to achieve your goal also by adding the files manually.

    The syntax is nowadays a bit different. In languages/yu.php:

    <?php
    
    return array(
        'foo' => 'bar',
    );
    

    You may have a syntax error somewhere in your translations file. Test this by temporarily removing all the strings from the language file, and checking if the error goes away.

  • @Juho: could the error be caused because this custom language would have a language code ("yu") not included in the array of allowed language codes? I'm not sure if this array is only checked when making a new Elgg release or if the array is also checked for example when the cache is built up / refreshed.

    @Miloš Milutinović: If the problem is caused by a language code / language file name not known to Elgg you could name you files instead as one of the known languages (e.g. using the name of Serbian, or Croatian, or Bosnian...) to see if the translations are used then. Of course, you would have to select a language you don't intend to use otherwise. For getting the "correct" language name in the language selection you would have to override the corresponding language string for this language, too, e.g. when using the Croatian language code for naming your files you would have to add the line

    "hr" => "Yugoslavian",

    within one of your custom language files (or rather replace the corresponding line in your translation of Elgg's main language file).

    Or you could test if it helps to add your custom language code to the array of allowed language codes in engine/classes/Elgg/I18n/Translator.php (just adding it in the array returned in the function getAllLanguageCodes()). If this would fix the issue you would have to make sure to add it each time after upgrading Elgg though.