r3 - 06 Jul 2005 - 20:13:28 - KatieCappsParlanteYou are here: OSAF >  Projects Web  >  DevelopmentHome > InternationalizationProject > GlobalizationI18N


Globalization is providing the architecture and writing code such that the software performs as expected in any of the targetted end user locales, and can be fully localized.

Areas where there are locale-specific behavior include text display, text entry and editing (input methods, text wrapping, word selection, etc.), locale-aware date/time/number formatting, sorting, and searching.

Being fully localizable means that all translatable text and locale-specific data is loaded at run-time from data that is separate from code. Text messages are properly constructed from localizable templates. Locale-specific behavior (e.g. address layouts) is controlled by localizable data.

A Trivial Example

Just to get into the spirit of things, let's look at some of the code in Chandler.py:

def main():
        message = "while trying to start."
        application = wxApplication(redirect=False, useBestVisual=True)
        message = "and had to shut down."
    except Exception, exception:
        type, value, stack = sys.exc_info()
        formattedBacktrace = "".join (traceback.format_exception (type, value, stack))
        message = "Chandler encountered an unexpected problem %snn%s" % (message, formattedBacktrace)
        # @@@ 25Issue - Cannot create wxItems if the app failed to initialize
        dialog = wx.MessageDialog(None, message, "Chandler", wx.OK | wx.ICON_INFORMATION)

Some G11N issues with this code are:

  1. message gets loaded (in three different places) with hard-coded, non-Unicode strings.
  2. The end-user message assumes concatenation will work (base message + reason)
  3. The end-user message is constructed by a printf template (the localizer can't re-order parameters, though in this case that's probably OK)
  4. The dialog is loaded with a hard-coded title (possibly OK, if app name isn't localizable)

Here's another one from Application.py:

class wxApplication (wx.App):
    def OnInit(self):
        splashBitmap = self.GetImage ("splash")
        splash = wx.SplashScreen(splashBitmap,
                                 6000, None, -1, wx.DefaultPosition,
    def GetImage (self, name):
        return wx.Image("application/images/" + name + ".png", wx.BITMAP_TYPE_PNG).ConvertToBitmap()

This code is loading & displaying the splashscreen, but this splash.png image contains text. So the GetImage method should add the locale into the path or the file name, so that either you're loading application/images/en_US/splash.png or application/images/splash_enUS.png.

Python Issues

There's a first cut at discussing some of the issues with Python & Globalization at PythonI18N.

Readying your system for G18N

Edit | WYSIWYG | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r3 < r2 < r1 | More topic actions
Open Source Applications Foundation
Except where otherwise noted, this site and its content are licensed by OSAF under an Creative Commons License, Attribution Only 3.0.
See list of page contributors for attributions.