AniDB:AJAX development: Difference between revisions

Jump to navigation Jump to search
No edit summary
Line 112: Line 112:


==== Multilingual support ====
==== Multilingual support ====
[Sphere] Added this as afterthought.  I tried fooling around with the basic anime info xslt and managed to add in translation time multilingual support.  basically I created a very simple string table in another xml that specifies a language and a list of key-value pairs that denotes a key in some default language (english in this case) and a translated value.
[Sphere] Added this as afterthought.  I tried fooling around with the basic anime info xslt and managed to add in translation time multilingual support.  basically I created a very simple string table in another xml that specifies a language and a list of key-value pairs that denotes a key in some default language (english in this case) and a translated value.  This will convert all the static strings like menu items, field names etc to the language specified in the config section of the xml if it can be found.  If not, it will use the key as the original string.


Optionally, to save space by not using a long string as key, each entry in the string table could use the @id attribute instead, and references each string by a number.  Personally, I find using strings easier as it makes the original xsl more readable...
e.g.
<xsl:call-template name="getPresentString"><xsl:with-param name="key">'''main'''</xsl:with-param></xsl:call-template>
instead of
<xsl:call-template name="getPresentString"><xsl:with-param name="id" select="'1'" /></xsl:call-template>
example of xml with string table (each language xml can have more than one string table each corresponding to a different language). 


<nowiki>
<presentation>
<presentation>
<animeinfo>
<animeinfo>
<stringtable lang="xx">
<stringtable lang="xx">
<string id="1"><key>main</key>
<string id="1"><key>main</key>
  <value>niam</value></string>
  <value>niam</value></string>
<string><key>search</key>
<string><key>search</key>
  <value>hcraes</value></string>
  <value>hcraes</value></string>
<string><key>calander</key>
<string><key>calander</key>
  <value>rednalac</value></string>
  <value>rednalac</value></string>
</stringtable>
</stringtable>
</animeinfo>
</animeinfo>
</presentation>
</presentation>
</nowiki>


Can also potentially derive which language xml to use by filename... e.g. animeinfo.it.xml, animeinfo.fr.xml etc.  So when AJAX kicks in, it can try to load the correct language file based on default language, or in the absense of the file, use back english (which are embedded as keys in the xsl, so it does not need a separate language file)
Also, the skeleton of a language file can be automatically generated by parsing an xslt and search for '''<xsl:call-template name="getPresentString">''' and then parse the key, and the unique ones in a dummy language xml in the correct structure.  This allows people to use the dummy xml to do translation easier.
I actually use <presentation> as the root of "language" file has it could potentially be expanded to point to a wider range of resources.. e.g. some images representing buttons with rendered text may need different version for different language, so they can potentially be embedded into the more appropriately named localization xml file as well.


== Comments, propositions and whatever else ==
== Comments, propositions and whatever else ==
21

edits

Navigation menu

MediaWiki spam blocked by CleanTalk.
MediaWiki spam blocked by CleanTalk.