×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Regular Contributor
    Join Date
    Apr 2007
    Location
    Lublin, Poland
    Posts
    81

    Localizing an application

    Hi,

    I'd like to localize (or globalize, or internationalize or whatever the word is) my application,
    meaning I'd like to have some nice local language strings it it.

    Is there some proper way to handle it? I don't really know how you do it in "full" python. I've noticed a gettext module, but it's not in pys60, so I didn't dig into it.

    So how would you do it?
    whatever happens happens

  2. #2
    Super Contributor
    Join Date
    May 2004
    Location
    Tampere, Finland
    Posts
    524

    Re: Localizing an application

    Quote Originally Posted by janekw_ View Post
    I'd like to localize (or globalize, or internationalize or whatever the word is) my application, meaning I'd like to have some nice local language strings it it.
    I did this once:

    Code:
    import appuifw
    
    # Emulate gettext, which is not available in PyS60.
    if appuifw.app.title == u"Ohjelma":
        # Finnish texts
        fintexts = {
            u"Refresh"                  : u"Päivitä",
            u"Exit"                     : u"Poistu",
            u"Initializing..."          : u"Alustetaan...",
            u"Finding services..."      : u"Etsitään palveluja...",
            u"Reading list..."          : u"Luetaan listaa...",
            u"No services available"    : u"Palveluja ei löytynyt",
            u"Program finished"         : u"Ohjelman ajo päättyi",
            u"Run-time error"           : u"Ajoaikainen virhe"
        }
        def _(s):
            return fintexts.get(s, s)
    else:
        # Fall back to English texts.
        def _(s):
            return s
    
    # ...
    
    # Each time a localized string is required:
    message = _(u"Finding services...")
    It is by no means an ideal way to do things, but it works for relatively small applications. You need to provide different application titles in each supported language by using the "--caption" parameter of Ensymble or py2sisng. (This was before there was any other way of determining the phone language. There may be better ways of achieving that, these days.)

  3. #3
    Nokia Developer Moderator
    Join Date
    May 2007
    Location
    21.46 N 72.11 E
    Posts
    3,796

    Re: Localizing an application

    This really wont work in as a perfect solution.Every time you have to add all the strings..But i think for now we do not have a substtution so good one jethro.fn
    Its really a nice idea
    Pankaj Nathani
    www.croozeus.com

  4. #4
    Regular Contributor
    Join Date
    Apr 2007
    Location
    Lublin, Poland
    Posts
    81

    Re: Localizing an application

    Nice, jethro.fn
    Thanks, I'll give it a try.
    whatever happens happens

  5. #5
    Super Contributor
    Join Date
    May 2004
    Location
    Tampere, Finland
    Posts
    524

    Re: Localizing an application

    Quote Originally Posted by croozeus View Post
    This really wont work in as a perfect solution.Every time you have to add all the strings..
    That's pretty much what you have to do with any localization solutions, gettext et al. Although there are many gettext-compatible tools to assist in the task (KBabel, gtranslator...)

Similar Threads

  1. AutoStart My application at bootup
    By prakashs in forum Symbian
    Replies: 7
    Last Post: 2009-03-24, 10:06
  2. Replies: 2
    Last Post: 2007-02-06, 15:16
  3. 3250: Too many SMSs received crash the application
    By kewldeep in forum Mobile Java General
    Replies: 4
    Last Post: 2007-01-27, 00:00
  4. Replies: 0
    Last Post: 2005-05-28, 10:20
  5. Replies: 0
    Last Post: 2003-02-03, 08:08

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×