SMF Support > Language Specific Support

Detecting the current user's language

(1/2) > >>

I've read several threads with similar titles, but none of them answered my question, and I have yet to find a thread that tells me what I wish to know, so I decided to start my own thread on this issue.

I'm working on a mod that uses a different sort of CAPTCHA script (yes, I know... NOT ANOTHER one!), and this script utilizes support for non-English languages. What I'd like to know is if there's a variable within SMF that already "knows" the currently set language code (e.g. 'en' for English, 'de' for German, etc.)  so that I may pass it (or a variable based on it, if it's not already in ISO 639-2 format) to the CAPTCHA script. Take a look at this image:
for an example of the script in Spanish, to see what I'm referring to. My script supports English, French, Spanish, German, Dutch and Croatian at this point, and I plan on adding other languages in the future. Having access to a "language variable" of some sort or another would go a long way toward making this mod more successful. :)

Hello there and welcome to smf community.

So if i understood, you just need language codes for languages that you would like to add to your mod, and which smf uses?
If so, you can find it in string $txt['lang_dictionary'] in index.{language}.php file though.

Let us know if you have some sort of list of languages that you would like to add to your mod, so we can give you dictionary codes.


Ideally, yes, that would be great, Dzonny. :)
I found index.english.php in the languages directory, so I'll read through that, and see what I can glean from it. I also found the variable $language within the SMF code this morning, and it seems to be useful (to a degree), as it seems to be currently set to 'english' in my install (I only understand English, personally). I can use the following code to translate that value into something more useful:

--- Code: ---    $C4us_languages = array(
      'german'   => 'de',
      'english'  => 'en',
      'spanish'  => 'es',
      'french'   => 'fr',
      'dutch'    => 'nl',
      'croatian' => 'hr',
    $C4us_lang_code = (!empty($C4us_languages[$language])) ? $C4us_languages[$language] : 'en';

--- End code ---

And then use the variable $C4us_lang_code to apply the appropriate ISO 639-2 language code to my script. The only problem I see with that is if the variable $language uses different values for the language names ('e.g. 'espanol' for Spanish), in which case I would have to make the requisite changes to my code, above. :)

As i said, you can post a list of languages that you would like to add to your mod so i can help you about those codes. Also you can find them yourself, but you'll have to install languages which u would like to add yo your mod firstly and then see lang_dictionary string in index.language.php.


Thanks, Dzonny. For the time being, the only languages I'll be supporting (and therefor needing to install) are the ones I've already listed, above. I'll only be adding new languages in the future "by request", as some languages (Chinese & Japanese, for example) would be most difficult to add support for, for a lot of reasons. In the mean-time, I'll research adding those languages to my SMF dev install, and do some poking around, to see what I can learn. :)


[0] Message Index

[#] Next page

Go to full version