Adding new languages to your site

Last updated by Trajan Comments (10)

Adding a language to your site is very simple to do. JeanBS explained roughly how to do it. Here is some further detail.

Basics

Elgg deals in language files. Go to your root folder and you will find a languages folder. Open that and you'll find a 'en.php'. Open that in a text editor (I don't recommend notepad for this) and you'll see the layout of a language file. 

To alter the language all you need to do is change the following:

$english = array(

add_translation("en",$english);

to

 

$bengali = array(

add_translation("bn",$bengali);

 

Then simply edit the following text:

 

'login' => "Log in",

'loginok' => "You have been logged in.",

 

to

 

'login' => "blahblahblah",

'loginok' => "something.",

Remember to save as otherwise you will overwrite your en.php file.

Further

Every plugin (usually) has its own language file. You can find this out by going into the root folder of that plugin and seeing if there is a language folder. Open it up and check what you've got inside. Do the same operation as mentioned above in basics. 

Saving - Important

When you save a language file that's not en.php it must be encoded properly. (Notepad can't manage this easily). It must be encoded as UTF_8(w/o BOM). If you don't do this then you'll get a lot of question marks where you language should be.

Recommended Editor

I use this editor to do my work as it's very simple, clever and open source!

Good luck. 

  • I want to add a unicode language (Amharic). How am I going to do it. Please help

  • Line 894 of root/languages/en.php shows:

    "am" => "Amharic",

    So simply create a new language file in root/languages/ called am.php

  • do i have to install the font on the server? when i write in Amharic it shows on my browser only question marks

  • Is this going to make visitors or users on my site to select the particular language they want the site to display in?I mean translating a site into languages that suits users or visitors.

  • @kxx4 If you want users able to choose language use the language_selector plugin. Also I think users can change the language on their account settings

     

    Rodolfo Hernandez

    Arvixe/Elgg Community Liaison

  • @kxx4: When a user goes to his "settings" section (in the topbar) he is able to set his "language". The languages available are automated depending on which language files are in your plugin folders and root/languages folder.

    If you download a language pack such as "German" and put it into your elgg install "German" will appear in that dropdown. Conveniently, the dropdown also shows the percentage of completion for that language. Incomplete sections appear in English (usually).

    The language_selector plugin that rj mentions is good. It shows a row of flags on every page. Clicking the flag changes the user's language settings. One thing to mention, I have had trouble with the plugin in a 1.7+ environment. It tends to stop the logging in action from completing, not sure why.

    @Amir: sorry it took me so long to get back to you. Most likely you are not saving the language file in the correct way. You must make sure the encoding is UTF8 W/O BOM

  • @rjcalifornia  and trajan: Thanks for this suggestion,When I added the language_selector plugin to my 1.7.6 version, the features installed well.

    1.what is the of "Enter the minimum amount of completeness for languages to show up in the language selector",and is it measured in %?i need to understand this terms in order to make proper setting of the plugin,i set it to 50 but have not seen anything .

    2.I did not see any change on the site on my localhost as I tried it using the default elgg site.I didnt see the country flags on the header as well.

     

  • @kxx4

    1) Enter minimum amount means the percentage of completeness for the language option to show up. If you go to 'Site Administration' in your admin backend and scroll down you will see a dropdown with language. Open that up and you will see all the languages that elgg has found language files for. Next to each one there will be a percentage figure. Here's an example:

    English
    French 57.84%

    This means that elgg has found language files that cover 57.84% of the total language used by elgg in English language files. 

    If all the other languages are below 50% on your site then the language_selector will not offer them to users as an option.

    2) The country flags have an on/off switch in the 'Tools Administration' plugin settings section. You have to turn them on. They are controlled by the percentage you entered (50%) in the first field. When any of the languages on your site reach over 50% the flags will appear.

    N.B. The flag for English will only appear when there is another flag to go with it. 

  • This means that elgg has found language files that cover 57.84% of the total language used by elgg in English language files. 

    Should be:

    This means that elgg has found French language files that cover 57.84% of the total language used by elgg in English language files. 

  • Nice Posting and It helps me to add language. Thanks everybody.