Difference between revisions of "OpenEMR Internationalization Development Guide"

From OpenEMR Project Wiki
 
(7 intermediate revisions by one other user not shown)
Line 1: Line 1:
__TOC__
==Translation function==
==Translation function==
:The translation is done by the xl() custom function, which can be found at openemr/library/translation.inc.php. Its semantics are very simple.
:The translation is done by the xl() custom function, which can be found at openemr/library/translation.inc.php. Its semantics are very simple.
Line 5: Line 6:
<pre>xl('translate this')</pre>
<pre>xl('translate this')</pre>
:By default the function will return the translation. First it uses the LANGUAGE constant defined to pick the translation. Second it goes for the translation, if none is found, then the same string entered is used and returned as is. Another example of use includes:
:By default the function will return the translation. First it uses the LANGUAGE constant defined to pick the translation. Second it goes for the translation, if none is found, then the same string entered is used and returned as is. Another example of use includes:
<pre>echo ("this and " . xl('translate this') . " that too");</pre>
<pre> echo ("this and " . xl('translate this') . " that too");</pre>
:Also note that comments can be included in the constants (and definitions) to help provide context for some constants to developers. For example, the constant '''to''' can be confusing in Dutch, where using to for ranges (ie. <date> to <date>) is different than when addressing where a message is going to (ie. to Brady). So, can place a comment in code, such below to specify this constant is being used:
 
 
:Also note that comments can be included in the constants (and definitions) to help provide context for some constants to translators. For example, the constant '''to''' can be confusing in Dutch, where using to for ranges (ie. <date> to <date>) is different than when addressing where a message is going to (ie. to Brady). So, can place a comment in code, such below to specify how the constant is being used:
<pre>xl('to{{range}}')</pre>
<pre>xl('to{{range}}')</pre>
The translation engine removes the comment, of course, when displaying it.  [[English_Constants_Descriptions#Constants_with_comments|See this wiki page to see the current constants that contain comments.]]
:The translation engine removes the comment, of course, when displaying it.  [[English_Constants_Descriptions#Constants_with_comments|See this wiki page to see the current constants that contain comments.]]
 
 
:To find more options for translation look within: '''explanationhtmlspecialchars.inc.php'''
 
:: <pre> $para_class = attr($db_data); //is escaped(including quotes)</pre>
:: <pre> $para_content = text($user_data); //is escaped(not including quotes)</pre>
:: <pre> $title_text = xla('My Title'); //is translated and escaped(including quotes) </pre>
 
:: <pre> $header_text = xlt('My Header'); //is translated and escaped(not including quotes) </pre>
::: <pre> echo "<h3>$header_text</h3><p class='$para_class' title='$title_text'>$para_content</p>\n" </pre>
 
:: <pre> See more at: http://www.open-emr.org/wiki/index.php/Codebase_Security#SQL-Injection_and_Cross-Scripting_Prevention </pre>
 
 
:Further details and rules on use can be found on the wiki here [[Development_Policies#Internationalization|Development Policies - Internationalization]]
:Further details and rules on use can be found on the wiki here [[Development_Policies#Internationalization|Development Policies - Internationalization]]
:There are also wrappers to the xl() function that are used infrequently in specific situations. Please refer to openemr/library/translation.inc.php for more details.
:There are also wrappers to the xl() function that are used infrequently in specific situations. Please refer to openemr/library/translation.inc.php for more details.
Line 19: Line 39:
:Here are the Previous sourceforge forums threads related to the internationalization project:
:Here are the Previous sourceforge forums threads related to the internationalization project:
::General Topic Threads
::General Topic Threads
:::*[http://sourceforge.net/projects/openemr/forums/forum/202506/topic/3439721 Most Recent]
:::*[http://sourceforge.net/p/openemr/discussion/202506/thread/83bc0f77 Most Recent]
:::*[http://sourceforge.net/projects/openemr/forums/forum/202506/topic/3279061 Third]
:::*[http://sourceforge.net/projects/openemr/forums/forum/202506/topic/3279061 Third]
:::*[http://sourceforge.net/projects/openemr/forums/forum/202506/topic/3130655 Second]
:::*[http://sourceforge.net/projects/openemr/forums/forum/202506/topic/3130655 Second]

Latest revision as of 23:44, 16 April 2014

Translation function

The translation is done by the xl() custom function, which can be found at openemr/library/translation.inc.php. Its semantics are very simple.
xl(string)
Which with examples means:
xl('translate this')
By default the function will return the translation. First it uses the LANGUAGE constant defined to pick the translation. Second it goes for the translation, if none is found, then the same string entered is used and returned as is. Another example of use includes:
 echo ("this and " . xl('translate this') . " that too");


Also note that comments can be included in the constants (and definitions) to help provide context for some constants to translators. For example, the constant to can be confusing in Dutch, where using to for ranges (ie. <date> to <date>) is different than when addressing where a message is going to (ie. to Brady). So, can place a comment in code, such below to specify how the constant is being used:
xl('to{{range}}')
The translation engine removes the comment, of course, when displaying it. See this wiki page to see the current constants that contain comments.


To find more options for translation look within: explanationhtmlspecialchars.inc.php
 $para_class = attr($db_data); //is escaped(including quotes)
 $para_content = text($user_data); //is escaped(not including quotes)
 $title_text = xla('My Title'); //is translated and escaped(including quotes) 
 $header_text = xlt('My Header'); //is translated and escaped(not including quotes) 
 echo "<h3>$header_text</h3><p class='$para_class' title='$title_text'>$para_content</p>\n" 
 See more at: http://www.open-emr.org/wiki/index.php/Codebase_Security#SQL-Injection_and_Cross-Scripting_Prevention 


Further details and rules on use can be found on the wiki here Development Policies - Internationalization
There are also wrappers to the xl() function that are used infrequently in specific situations. Please refer to openemr/library/translation.inc.php for more details.

Translation Pipeline

For those interested in the actual software/scripts (pipeline) that created the online google docs translation spreadsheet and then utilizes it for insertion in OpenEMR; they are kept in this directory (The README file is the best place to get an overview of the process):

Translation Development Discussions

Here are the Previous sourceforge forums threads related to the internationalization project:
General Topic Threads
Specific Topic Threads