-
Notifications
You must be signed in to change notification settings - Fork 71
Gettext
Example code needs updating for version 3.4.8 -- until then, check out the GettextExample code.
Gettext is a library for "translating" applications to multiple languages. Seaside-Gettext allows you to use gettext from Seaside applications.
In a recent image, DoIt:
BaselineOfSeaside3 load: #('Gettext-Examples').
The easiest way to translate a string is using the #translate:
message on the render canvas.
html translate: 'text to translate'
This will use content negotiation to find the first language that's supported by both your system and the user. If you want the set the user language to a specific one send #locale:
to the current session. If you want to translate to a specific language use
html translate: 'other text to translate' to: aWALocale
This doesn't work for attributes. In these cases you want to use #seasideTranslated
on String
html image url: aWAUrl; altText: 'sunrise at the beach' seasideTranslated
or
html image url: aWAUrl; altText: ('sunrise at the beach' seasideTranslatedTo: aWALocale)
There are some cases when neither of these approaches work. Mainly when the method that contains the literal is executed outside of a Seaside request. In these cases you can use #seasideLazyTranslated
descriptionFirstName
^ MAStringDescription new
accessor: #firstName;
label: 'First Name' seasideLazyTranslated;
priority: 100;
yourself
- write your application using the API above
- register your domain. A domain is a way to group strings, you might
- have Pier and a reporting application running in the same image and want each to use it's own dictionary:
TextDomainManager registerCategoryPrefix: 'Seaside-Gettext-Examples' domain: 'gettext'
- export the template
WAGetTextExporter new exportTemplate
- create the translation files e.g. using poedit
- put the translation files in
locale/<locale>/LC_MESSAGES/<domain>.(po|mo)
- done
One of the nice things about gettext is that there are external tools like poedit to manage the translation files which you can give to your translators. No more need to mess around with Excel. There are also tools that display how much of your application is already translated.
To use Seaside-Gettest in an application a WALocalizationContextFilter
has to be present. An easy way to do this is override initializeFilters
in your session class and add it there. See Seaside-Gettext-Examples for an example.
Changelogs
- (newer changelogs, see https://github.com/SeasideSt/Seaside/releases)
- 3.4.0
- 3.3.0
- 3.2.4
- 3.2.2
- 3.2.1
- 3.2.0
- 3.1.3
- 3.1.2
- 3.1.1
- 3.1.0
- 3.0.11
- 3.0.9
- 3.0.8
- 3.0.7
- 3.0.6
- 3.0.5
- 3.0.4
- 3.0.3
- 3.0.2
- 2.8
- 2.7
- Past Releases
Development
Documentation
- Configuration and Preferences
- Embedding Subcomponents
- Maintaining State
- Generating HTML
- CSS and Javascript
- Debugging Seaside Applications
- Links, Forms and Callbacks
- Development Tools
- Call and Answer
- Naming URLs
- Security Features
- Securing Seaside Applications
- Seaside-REST
- Add-On Libraries
- Persistence
- Gettext
- FileLibrary
- The Render Tree
- PDF Generation
- Long-Term Issues
- Ajaxification
- Web Components
- Big Issues
Sprints