[Gambas-user] Shipping translations for my project

Ron ron at ...1740...
Fri Oct 31 10:57:54 CET 2008


M0E Lnx schreef:
> And that's what I'm doing at the moment.
> But that only works when the application is ran inside the IDE
>
> if I run it outside the IDE, then it doesn't list the languages not
> even when ran from the same directory that contains .lang
>
> suggestions?
>
>
> On Thu, Oct 30, 2008 at 1:03 PM, Benoit Minisini
> <gambas at ...1...> wrote:
>   
>> On jeudi 30 octobre 2008, M0E Lnx wrote:
>>     
>>> Right... I understand that..
>>> But settings System.Language = "ft_FR" will only translate my
>>> application to French if a French translation is available .....
>>> correct?
>>>
>>> And there lies my question... I want to list the translations
>>> available for my application... (I have only 3 at the moment, but
>>> there will be more)
>>> The user should see these in a listbox and pick one.... but where do I
>>> get the values for the listbox (without having to hardcode a list
>>> there)
>>>
>>>       
>> There is nothing at the moment, except doing: Dir(".lang", "*.mo")
>>
>> --
>> Benoit Minisini
>>
>> -------------------------------------------------------------------------
>> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
>> Build the coolest Linux based applications with Moblin SDK & win great prizes
>> Grand prize is a trip for two to an Open Source event anywhere in the world
>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>> _______________________________________________
>> Gambas-user mailing list
>> Gambas-user at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>>
>>     
>
>   

I have hardcode this, the available translations for my project are 
known, so why not implement it like this, and the add a language to the 
code when I have made a new one.

Main.sLanguage holds locale from settings

' set language and run application
PUBLIC FUNCTION Main() AS Boolean

  ' load program settings
  Main.GetConfig()
  ' set language
  System.Language = Main.sLanguage
  ' open main form
  FMain.Show()

END

Change settings form:
  SELECT CASE Main.sLanguage
    CASE "en_US.UTF-8"
      cmbLanguage.Text = "English"
      pbLanguage.Picture = Picture["icons/en.png"]
    CASE "nl_NL.UTF-8"
      cmbLanguage.Text = "Dutch"
      pbLanguage.Picture = Picture["icons/nl.png"]
  END SELECT


  SELECT CASE cmbLanguage.Text
    CASE "English"
      Main.sLanguage = "en_US.UTF-8"
      pbLanguage.Picture = Picture["icons/en.png"]
    CASE "Dutch"
      Main.sLanguage = "nl_NL.UTF-8"
      pbLanguage.Picture = Picture["icons/nl.png"]
  END SELECT

Not the best way maybe, but it seems to work ok.

Apart from this problem, the user should have the correct locale 
installed otherwise he will get this error in console (ide only) when he 
choose a language in my app:
WARNING: cannot switch to language 'nl_NL.UTF-8'. Did you install the 
corresponding locale?

He needs to do
apt-get install language-pack-nl-base
first then.
I have no idea how to catch this (apart from documenting it)



Regards,
Ron_2nd





More information about the User mailing list