Support Forum

Language files

LE LeoS
LeoS
Member

I have language files for Dutch and German in …sp-resources/forum-language. The default language is Dutch. I inserted the language switcher code in the footer, expecting to see a choice between (default) Dutch and German. To my surprise there is also the option to switch to English (en). Where is that coming from and how do I get rid of it?

Next, the German language option is listed as ‘de_DE’. Can I change that somehow into ‘Deutsch’?

And BTW, talking about language files, do I yes or no have to rename them from say ‘sp-subs-de.mo’ to ‘sp-subs-de_DE.mo’?

13 Answers

New Answer

MP Mr Papa
Mr Papa
Member

the standard wp string for German language is just de and not de_DE… but if the wp translation file you are using is de_DE and that is what you have put in the language string in the wp config file, then yes the filename of our translation files must match…

afraid there is not currently any way to remove the English translation as it comes with the forum since its the forum default language… and no one has ever asked to remove it…  but will add it to the list to see if possible to remove it in the future…

interesting question on the language in the select box…  it just use the translation file name, but certainly understand a friendly display name instead – once again first request!  but not really sure how to do it either…  guess we would have to add some sort of admin UI for changing or provide strings for translation of all possible languages (otherwise the friendly display would be in English)…  or perhaps provide a filter on the displayed names so each user can easily replace just what is being used…  have added it to the list…

LE LeoS
LeoS
Member

The WP part of the site is solely in Dutch, so WPLANG is set to nl_NL. So I guess it doesn’t matter much how the German language files are called as long as the first part is sp-de?

I experimented a little by calling the German language files ‘Deutsch’, and it worked – but only once.

YS Yellow Swordfish
Yellow Swordfish
Member

If you feel up to making a small edit to the plugin file I can define a filter now and let you have it and also ensure that it gets into the next release of the plugin…

LE LeoS
LeoS
Member

That would be great, please do! It appears rather ‘unfinished’ now.

YS Yellow Swordfish
Yellow Swordfish
Member

Well I will guarantee that the filter remains but this might not be the way we choose to handle it longer term. We are actually thinking of maybe giving it a little admin UI to make things easier. But this will work now.

The first file to edit is – by default – 

wp-content/sp-resources/forum-plugins/user-selection/template-tags/sp-user-selection-tags.php

Locate the block of code that looks like this (in the languages section):

foreach ($langs as $lang) {
    $lang = str_replace('sp-', '', trim($lang));
    $selected = (isset($_COOKIE['language']) && $lang == $_COOKIE['language']) ? ' selected="selected" ' : '';
    $out.= '<option'.$selected.' value="'.esc_attr($lang).'">'.esc_html($lang).'</option>';
}

and replace it with the following, Note there is one new line of code and one other has been modified:

foreach ($langs as $lang) {
    $lang = str_replace('sp-', '', trim($lang));
    $display = apply_filters('sph_LanguageDisplay', $lang);
    $selected = (isset($_COOKIE['language']) && $lang == $_COOKIE['language']) ? ' selected="selected" ' : '';
    $out.= '<option'.$selected.' value="'.esc_attr($lang).'">'.esc_html($display).'</option>';
}

Then finally you need to define a filter function in the spFunctions.php file of your Simple:Press theme. This will be in the /templates folder. This should look something like this:

add_filter('sph_LanguageDisplay', 'my_Lang_Names');
function my_Lang_Names($lang) {
    if($lang == 'it') {
        $lang = 'Italian';
    } elseif ($lang == 'fr') {
        $lang = 'French';
    } elseif ($lang == 'de') {
        $lang = 'German';
    return $lang;
}

Of course you will need to supply the language codes that you are actually using and the country names you prefer to use. Define as few or as many as you need but this gives you a coding template to work with.

I am afraid this will not remove the English entry. That will have to come later I am afraid.

LE LeoS
LeoS
Member

Thanks! It works. 

I also changed in line 85 the ‘Select Language’ label to ‘Kies taal / Bitte wählen’

Maybe the option to change the label is something to integrate into the admin UI thingy also?

YS Yellow Swordfish
Yellow Swordfish
Member

LeoS said
Thanks! It works. 

I also changed in line 85 the ‘Select Language’ label to ‘Kies taal / Bitte wählen’

Maybe the option to change the label is something to integrate into the admin UI thingy also?

Well no – those labels are themselves within the plugin’s own translation file which is really where they belong.

LE LeoS
LeoS
Member

Yellow Swordfish said

LeoS said
Thanks! It works. 

I also changed in line 85 the ‘Select Language’ label to ‘Kies taal / Bitte wählen’

Maybe the option to change the label is something to integrate into the admin UI thingy also?

Well no – those labels are themselves within the plugin’s own translation file which is really where they belong.

Ideally yes, but changing it in the language file doesn’t seem to do anything.

While we’re at it, I’m pulling my hair out trying to find the location of the word avatar on the Profile page. My forum is for older people, they have no idea what an avatar is, so I want it to simply say Image.

YS Yellow Swordfish
Yellow Swordfish
Member

I can see that the selecter plugin only has about 4 languages where people have added translations and approved them. German is one of them.

The profile tabs and menus are unique in that you can change those main labels in the Profiles Tabs and menus option of the forum admin. In-line form text will reside in the core SP po/mo file.

LE LeoS
LeoS
Member

I just updated the Language and Theme Selection to version 1.2 Renaming the non-default language files to anything you want works great, thanks.

However, the site default language is displayed as ‘Default theme’ if it is English and as ‘Standaard theme’ in not-so-correct Dutch. Is there anything I can do to change that to something more meaningful to Dutch people like ‘Nederlands’?

MP Mr Papa
Mr Papa
Member

you can update the translation – unfortunately we cannot do that for languages since we dont speak all the languages and rely on contributions for the translations…

but actually a bit confused as to how it might have gotten translated in the first place since it shouldnt be and should just be the name of the theme…  unless you mean the English version is actually ‘Site Default’ and that got translated…

LE LeoS
LeoS
Member

Thanks, maybe I’m not explaining this clearly enough. I’m talking about the first entry in the dropdown box. On a Dutch site it says ‘Standaard theme’. How can I change this? It’s not in the language file, as far as I can see.

MP Mr Papa
Mr Papa
Member

Think I follow – was clarifying your statement of “default” for English…. We don’t do that and asked if you meant “default theme”…

But my answer still holds, you can correct the language translation… It’s not within simple press itself….

In future, we might be able to offer a filter too but now, the translation just needs to be updated….