i18n.txt
3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
KnowledgeTree Internationalisation (i18n)
-----------------------------------------
Overview
--------
Support for i18n has been added to the KnowledgeTree- however, we are not in a position to
begin translating the KnowledgeTree until all the text and graphics in the application are marked for translation.
This is a mammoth task that will require the support and aid of the KnowledgeTree community :)
Requirements
------------
i18n requires gettext (http://www.gnu.org/software/gettext) and the gettext php module to work
(see http://php.net/gettext for installation instructions).
Completed Tasks and Implementation Details
------------------------------------------
- i18n/<locale>/LC_MESSAGES/knowledgeTree.mo
knowledgeTree.po
/graphics
- gettext support loaded if php module available
- login, dashboard, document browse view i18n'd
- checks the browser's Accept-Language header and uses that language (if there is a translation for it)
The TODO List
-------------
The rest of the KnowledgeTree needs to be i18n'd.
Here are some guidelines for adding gettext support to the KnowledgeTree.
- find translatable strings and wrap literals with _() eg.
original:
$sToRender .= "\t\t\t\t<th class=\"sectionHeading\" colspan=\"2\"><font color=\"ffffff\">Pending Web Documents</font></th>\n";
i18n'd:
$sToRender .= "\t\t\t\t<th class=\"sectionHeading\" colspan=\"2\"><font color=\"ffffff\">" . _("Pending Web Documents") . "</font></th>\n";
- if strings are concatenated with dynamic content use sprintf eg.
original:
$sToRender .= "\t\t<td>Hi " . $sUserName . ", welcome back to the " . lookupField($default->organisations_table, "name", "id", $default->organisationID) .
"DMS, part of the Knowledge Tree</td>\n";
i18n'd:
$sToRender .= "\t\t<td>" . sprintf(_('Hi %s, welcome back to the %s DMS, part of the Knowledge Tree'),
$sUserName,
lookupField($default->organisations_table, "name", "id", $default->organisationID)) .
"</td>\n";
- images- use the imgSrc function to dynamically use the images in the i18n directory (if they exist) eg.
original:
$sToRender .= "\t\t<td><img src=\"$default->graphicsUrl/welcome.gif\" border=\"0\"/></td>\n";
i18n'd:
$sToRender .= "\t\t<td><img src=\"" . imgSrc("welcome.gif") . "\" border=\"0\"/></td>\n";
Testing
-------
- install gettext command line utilities
- run xgettext to generate .po files eg.
xgettext --files-from=i18n/file-list -LPHP --keyword=_ --no-wrap --msgid-bugs-address="kt-i18n@jamwarehouse.com" -o knowledgeTree.po
- write a test translation by editing the po file appropriately. if you have problems with the order of parameters, because your language's
ordering is different then in english. You can use the $ to change order eg:
msgid "Upgrading item %d of %d"
msgstr "... %2$d ... %1$d ..."
- construct the right directory structure inside i18n eg.
$ mkdir -p i18n/es/LC_MESSAGES/
- use msgfmt to compile your translated .po file to a .mo
$ msgfmt --check $knowldgeTree.po --output-file=i18n/$es/LC_MESSAGES/knowledgeTree.mo
- change $default->defaultLanguage in config/environment.php and verify your translation.
$Id$