<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://dev.eiffel.com/index.php?action=history&amp;feed=atom&amp;title=Internationalization%2FSA_developer_manual</id>
		<title>Internationalization/SA developer manual - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://dev.eiffel.com/index.php?action=history&amp;feed=atom&amp;title=Internationalization%2FSA_developer_manual"/>
		<link rel="alternate" type="text/html" href="https://dev.eiffel.com/index.php?title=Internationalization/SA_developer_manual&amp;action=history"/>
		<updated>2026-05-16T01:54:19Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.24.1</generator>

	<entry>
		<id>https://dev.eiffel.com/index.php?title=Internationalization/SA_developer_manual&amp;diff=4195&amp;oldid=prev</id>
		<title>Leo: copy/paste-moved from Internationalization/developer manual</title>
		<link rel="alternate" type="text/html" href="https://dev.eiffel.com/index.php?title=Internationalization/SA_developer_manual&amp;diff=4195&amp;oldid=prev"/>
				<updated>2006-08-16T00:22:18Z</updated>
		
		<summary type="html">&lt;p&gt;copy/paste-moved from Internationalization/developer manual&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[Category:Internationalization SA project]]&lt;br /&gt;
&lt;br /&gt;
= How to design the software =&lt;br /&gt;
There is only a few things which can help you using our library, the most important one is dividing completely the logic of the program from the content.&lt;br /&gt;
In other words, you should write a class which contains all the strings you use in the program; so applying out system will be very easy.&lt;br /&gt;
&lt;br /&gt;
= How to use the library =&lt;br /&gt;
&lt;br /&gt;
Here you can find instructions on how to use our library; how to initialize the system and how to make the translations actually appear in your application.&lt;br /&gt;
&lt;br /&gt;
== Initialization ==&lt;br /&gt;
&lt;br /&gt;
To initialize the library you should have a class that inherits from the SHARED_I18N_LOCALIZATOR; this will bring you all the necessary infrastructure to start localizing your software.&lt;br /&gt;
&lt;br /&gt;
What to do?&lt;br /&gt;
* create datasource&lt;br /&gt;
* create datastructure&lt;br /&gt;
* load localizator&lt;br /&gt;
&lt;br /&gt;
=== Creating a datasource ===&lt;br /&gt;
&lt;br /&gt;
We equip you with a simple factory to create the sources, simply create an I18N_DATASOURCE_FACTORY&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[eiffel,N]&lt;br /&gt;
datasource_factory: I18N_DATASOURCE_FACTORY&lt;br /&gt;
&lt;br /&gt;
create datasource_factory.make&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
you now have the possibility to create a new source based on an mo file, as follows&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[eiffel,N]&lt;br /&gt;
datasource: I18N_DATASOURCE&lt;br /&gt;
&lt;br /&gt;
datasource_factory.use_mo_file(mo_file_path)&lt;br /&gt;
if datasource_factory.last_datasource /= Void then&lt;br /&gt;
  datasource := datasource_factory.last_datasource&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if something went wrong, you can alway fallback with an empty datasource&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[eiffel,N]&lt;br /&gt;
datasource_factory.use_empty_source&lt;br /&gt;
datasource := datasource_factory.last_datasource&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The datasource is ready, you should create a datastructure for storing the strings.&lt;br /&gt;
&lt;br /&gt;
=== Creating a datastructure ===&lt;br /&gt;
&lt;br /&gt;
We provide you with a simple factory to create datastructures, so follow the example&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[eiffel,N]&lt;br /&gt;
datastructure_factory: I18N_DATASTRUCTURE_FACTORY&lt;br /&gt;
&lt;br /&gt;
create datastructure_factory.make&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can now create, for example, an hash table&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[eiffel,N]&lt;br /&gt;
datastructure: I18N_DATASTRUCTURE&lt;br /&gt;
&lt;br /&gt;
datastructure_factory.use_hash_table&lt;br /&gt;
if datastructure_factory.last_datastructure /= Void then&lt;br /&gt;
  datastructure := datastructure_factory.last_datastructure&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and, even in this case, if something went wrong, you can create a dummy datastructure&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[eiffel,N]&lt;br /&gt;
datastructure_factory.use_dummy&lt;br /&gt;
datastructure := datastructure_factory.last_datastructure&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now that you have the datastructure ready, you can load the localizator.&lt;br /&gt;
&lt;br /&gt;
=== Loading the localizator ===&lt;br /&gt;
&lt;br /&gt;
It's important that you do this part before trying to localize any string, if not, the localizator would serve you what you pass as argument.&lt;br /&gt;
&lt;br /&gt;
Pass the source to the localizator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[eiffel,N]&lt;br /&gt;
i18n_use_datasource(datasource)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
then pass the datastructure&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[eiffel,N]&lt;br /&gt;
i18n_use_datastructure(datastructure)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and finally load the localizator with the new source and structure&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[eiffel,N]&lt;br /&gt;
i18n_load&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You now have a working localization environment!&lt;br /&gt;
&lt;br /&gt;
{{Warning|If you don't assign a source AND a structure AND then call load, the system will continue to use the old ones.}}&lt;br /&gt;
&lt;br /&gt;
== Localization ==&lt;br /&gt;
&lt;br /&gt;
Here you can find some instructions to translate the strings of you program, including substituting variables into templates.&lt;br /&gt;
&lt;br /&gt;
=== Translating simple strings ===&lt;br /&gt;
&lt;br /&gt;
If you have a simple string to translate, like this&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[eiffel,N]&lt;br /&gt;
simple_string: STRING&lt;br /&gt;
&lt;br /&gt;
simple_string := &amp;quot;A simple string&amp;quot;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
you only have to enclose the string by the simple i18n() function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[eiffel,N]&lt;br /&gt;
simple_string := i18n(&amp;quot;A simple string&amp;quot;)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
the system will then be charged of the translation in whatever language you've chosen.&lt;br /&gt;
&lt;br /&gt;
=== Translating plurals ===&lt;br /&gt;
&lt;br /&gt;
Sometimes you must change the translated string in relation with a variable; this piece of code&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[eiffel,N]&lt;br /&gt;
string: STRING&lt;br /&gt;
i: INTEGER&lt;br /&gt;
&lt;br /&gt;
if i = 1 then&lt;br /&gt;
  string := &amp;quot;There is 1 file&amp;quot;&lt;br /&gt;
else&lt;br /&gt;
  string := &amp;quot;There are more files&amp;quot;&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will be written as follows using our system&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[eiffel,N]&lt;br /&gt;
string := i18n_pl(&amp;quot;There is 1 file&amp;quot;, &amp;quot;There are more files&amp;quot;, i)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
the right form will be selected and displayed for you.&lt;br /&gt;
&lt;br /&gt;
=== Translating with templates ===&lt;br /&gt;
&lt;br /&gt;
{{Warning|We encourage you to use a stand alone template engine and not rely on our built-in functions, which will not be maintained.}}&lt;br /&gt;
&lt;br /&gt;
You can use our library to translate something like this&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[eiffel,N]&lt;br /&gt;
string := &amp;quot;Number &amp;quot; + i.out&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in this way&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[eiffel,N]&lt;br /&gt;
string := i18n_comp(&amp;quot;Number $1&amp;quot;, [i])&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and of course you can do the same with the plural forms&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[eiffel,N]&lt;br /&gt;
if i = 1 then&lt;br /&gt;
  string := &amp;quot;There is 1 file&amp;quot;&lt;br /&gt;
else&lt;br /&gt;
  string := &amp;quot;There are &amp;quot; + i.out + &amp;quot; files&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
would look like this&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[eiffel,N]&lt;br /&gt;
string := i18n_comp_pl(&amp;quot;There is 1 file&amp;quot;, &amp;quot;There are $1 files&amp;quot;, [i], i)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
we've so covered all the possibilities.&lt;br /&gt;
&lt;br /&gt;
= How to translate / use translation files =&lt;br /&gt;
&lt;br /&gt;
== Editing PO files == &lt;br /&gt;
&lt;br /&gt;
You can edit the PO files created with your preferred editor; some possible tools are listed [[Internationalization/tool_evaluation|here]].&lt;br /&gt;
&lt;br /&gt;
== Issues with MO files ==&lt;br /&gt;
&lt;br /&gt;
Into the header section of the PO file must be present the &amp;quot;Plural-Forms&amp;quot; header.&lt;br /&gt;
&lt;br /&gt;
It looks like this line:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Plural-Forms: nplurals=2; plural=(n!=1);&amp;quot;&lt;br /&gt;
&lt;br /&gt;
with &amp;quot;nplural&amp;quot; being the number of plurals of the destination language and &amp;quot;plural&amp;quot; the C-like function for finding the right plural form starting with an integer.&lt;/div&gt;</summary>
		<author><name>Leo</name></author>	</entry>

	</feed>