<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[FrontAccounting forum — How to translate words from the database]]></title>
	<link rel="self" href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=3798&amp;type=atom" />
	<updated>2013-01-30T11:27:08Z</updated>
	<generator>PunBB</generator>
	<id>https://frontaccounting.com/punbb/viewtopic.php?id=3798</id>
		<entry>
			<title type="html"><![CDATA[Re: How to translate words from the database]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=15382#p15382" />
			<content type="html"><![CDATA[<p>I finally managed to locate where to put the _() for the combo boxes to get translated.&nbsp; &nbsp; &nbsp; &nbsp; <br />It is in the file frontaccounting/includes/ui/ui_lists.inc&nbsp; &nbsp; around line 190.<br />The variable $contact_row[1] contains the expression taken from the database that you want to translate.<br />All you need to do is to add the middle line shown below.</p><p>&nbsp; &nbsp; &nbsp; &nbsp; $value = $contact_row[0];<br />&nbsp; &nbsp; $contact_row[1] = _($contact_row[1]);&nbsp; &nbsp;//&nbsp; &nbsp;this line is added<br />&nbsp; &nbsp; $descr = $opts[&#039;format&#039;]==null ?&nbsp; $contact_row[1] :</p><p>Then when you manually put the translations in the PO file and make a new MO file your combo boxes will also be translated.</p><p>Example:</p><p>The first 2 entries in the chart_types table are &quot;Current Assets&quot; and &quot;Inventory Assets&quot;.</p><p>Then add the following to your PO file:</p><p>#: from table chart_types<br />msgid &quot;Current Assets&quot;<br />msgstr &quot;Omløpsmidler&quot;</p><p>#: from table chart_types<br />msgid &quot;Inventory Assets&quot;<br />msgstr &quot;Anleggsmidler&quot;</p><p>The translation shown above is Norwegian, but you put the translation in your own language.</p><p>I have made a file of most of the database entries that should be translated and will try to make it available for all to download.</p>]]></content>
			<author>
				<name><![CDATA[haakon0603]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=14301</uri>
			</author>
			<updated>2013-01-30T11:27:08Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=15382#p15382</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: How to translate words from the database]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=15358#p15358" />
			<content type="html"><![CDATA[<p>Placed content in <a href="https://frontaccounting.com/fawiki/index.php?n=Devel.TranslationOfStringsInDatabase"><strong>Wiki</strong></a></p>]]></content>
			<author>
				<name><![CDATA[apmuthu]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=364</uri>
			</author>
			<updated>2013-01-29T02:25:57Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=15358#p15358</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: How to translate words from the database]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=15357#p15357" />
			<content type="html"><![CDATA[<p>Do not, in general, use php $ variables inside the translation text directly.</p><p>Check the <a href="https://frontaccounting.hg.sourceforge.net/hgweb/frontaccounting/frontaccounting/rev/e49c2066321f">3166</a>/<a href="https://frontaccounting.hg.sourceforge.net/hgweb/frontaccounting/frontaccounting/rev/8ceaaf82e8a7">3167</a> Mercurial for sprintf for example workarounds. Otherwise the litteral varable name will be parsed instead. Make sure every possible variable value has a translation in the .po/.mo files.</p><p>The lines (they seem okay in hindsight):<br /></p><div class="codebox"><pre><code>    label_cell(_($myrow[&quot;name&quot;]));//   here the _() is put
    label_cell(_($parent_text));//   here the _() is put
    label_cell(_($bs_text));//   here the _() is put</code></pre></div><p>should possibly be (%d for numbers and %s for strings) where every possible value of :<br /></p><div class="codebox"><pre><code>    label_cell(sprintf(_(&quot;%s&quot;), $myrow[&quot;name&quot;]));//   here the _() is put
    label_cell(sprintf(_(&quot;%s&quot;), $parent_text));//   here the _() is put
    label_cell(sprintf(_(&quot;%s&quot;), $bs_text));//   here the _() is put</code></pre></div><p>Even this may not work as intended since <strong>%s</strong> will be parsed as is and there is no preceeding or succeeding text to be translated. An eval() may have to be done on a cocatenated string containing the variable.</p><p>Try the following as well:<br /></p><div class="codebox"><pre><code>    label_cell(_(sprintf(&quot;%s&quot;, $myrow[&quot;name&quot;])));//   here the _() is put
    label_cell(_(sprintf(&quot;%s&quot;, $parent_text)));//   here the _() is put
    label_cell(_(sprintf(&quot;%s&quot;, $bs_text)));//   here the _() is put</code></pre></div><p>Maybe a check to see if <strong>$parent_text</strong> is empty before translation would be all that is needed:<br /></p><div class="codebox"><pre><code>    label_cell($empty(trim($parent_text)) ? &quot;&quot; : _($parent_text));//   here the _() is put</code></pre></div>]]></content>
			<author>
				<name><![CDATA[apmuthu]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=364</uri>
			</author>
			<updated>2013-01-29T01:48:54Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=15357#p15357</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: How to translate words from the database]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=15338#p15338" />
			<content type="html"><![CDATA[<p>Some places are easy to find and some are difficult to find.<br />The Account Types page is an example.<br />On the screen 2 of the combo boxes can easily be translated as you say, but the 2 others are difficult to find.</p><p>The 2 easy ones are found in the &quot;while&quot; statement starting around line 133 in the file /frontaccounting/gl/manage/gl_account_types.php.<br />In the label_cell function calls around line 150 the _() are inserted as shown below. When the correct translations are inserted in the PO file, they are translated correctly.<br />I found that the ($parent_text) could not be empty. You have to assign it some value. Otherwise it returns the whole PO file.</p><p>while ($myrow = db_fetch($result)) <br />{</p><p>&nbsp; &nbsp; alt_table_row_color($k);</p><p>&nbsp; &nbsp; $bs_text = get_account_class_name($myrow[&quot;class_id&quot;]);<br />&nbsp; &nbsp; $parent_text = &quot;-&quot;;<br />&nbsp; &nbsp; if ($myrow[&quot;parent&quot;] == &#039;-1&#039;) <br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; $parent_text = &quot;-&quot;;<br />&nbsp; &nbsp; } <br />&nbsp; &nbsp; else <br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; $parent_text = get_account_type_name($myrow[&quot;parent&quot;]) . &quot; &quot;;<br />&nbsp; &nbsp; }</p><p>&nbsp; &nbsp; label_cell($myrow[&quot;id&quot;]);<br />&nbsp; &nbsp; label_cell(_($myrow[&quot;name&quot;]));//&nbsp; &nbsp;here the _() is put<br />&nbsp; &nbsp; label_cell(_($parent_text));//&nbsp; &nbsp;here the _() is put<br />&nbsp; &nbsp; label_cell(_($bs_text));//&nbsp; &nbsp;here the _() is put<br />&nbsp; &nbsp; inactive_control_cell($myrow[&quot;id&quot;], $myrow[&quot;inactive&quot;], &#039;chart_types&#039;, &#039;id&#039;);<br />&nbsp; &nbsp; edit_button_cell(&quot;Edit&quot;.$myrow[&quot;id&quot;], _(&quot;Edit&quot;));<br />&nbsp; &nbsp; delete_button_cell(&quot;Delete&quot;.$myrow[&quot;id&quot;], _(&quot;Delete&quot;));<br />&nbsp; &nbsp; end_row();<br />}<br />--------------------------------------------------------------------------------------------------------------------------------------------<br />The 2 combo boxes at the bottom of the page are more difficult to handle. I have not managed to find out where to introduce the _(). I have tried several places in the &quot;gl_account_types.php&quot; file and in the ui_lists.php file and the gl_db_account_types.inc file but I cannot find out where to put them.</p><p>Do you have any suggestions where to put the _()?</p>]]></content>
			<author>
				<name><![CDATA[haakon0603]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=14301</uri>
			</author>
			<updated>2013-01-28T16:20:37Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=15338#p15338</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: How to translate words from the database]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=15305#p15305" />
			<content type="html"><![CDATA[<p>All the strings in database are user defined, so we cannot add them to *.po/*.mo file, just because we don&#039;t know what is content of your database. You can do it&nbsp; yourself if you have enough time for it:<br />1. add the strings from your database tables you want to be translated to all *.po language files you like;<br />2. translate them and generate *.mo files;<br />3. find all places in sources where the strings are displayed not translated, and add _() calls over respective variable/expression.</p><p>As you see recipe is simple, but you need to spent a couple of days to be satisfied.</p><p>Janusz</p>]]></content>
			<author>
				<name><![CDATA[itronics]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=89</uri>
			</author>
			<updated>2013-01-27T17:53:23Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=15305#p15305</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: How to translate words from the database]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=15304#p15304" />
			<content type="html"><![CDATA[<p>Yes, and then the phrase &quot;Payment due within 10 days&quot; taken from the database would appear in the PO file as</p><p>msgid &quot;Payment due within 10 days&quot;<br />msgstr &quot;whatever it is in your language&quot;</p><p>and whenever this phrase appeared in the combo boxes it would be translated to your language.</p><p>So my question is: Is there a way to fix this?</p>]]></content>
			<author>
				<name><![CDATA[haakon0603]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=14301</uri>
			</author>
			<updated>2013-01-27T16:41:55Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=15304#p15304</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: How to translate words from the database]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=15297#p15297" />
			<content type="html"><![CDATA[<p>Translatable Text comes from language *.mo files compiled from the translated empty.po files named according to your language.</p><p>The Wiki pages for <a href="https://frontaccounting.com/fawiki/index.php?n=Help.InstallUpdateLanugages">Language</a> and <a href="https://frontaccounting.com/fawiki/index.php?n=Devel.UpdateEmptyPoFiles">Translation String updation</a> would be useful.</p>]]></content>
			<author>
				<name><![CDATA[apmuthu]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=364</uri>
			</author>
			<updated>2013-01-27T13:59:52Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=15297#p15297</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: How to translate words from the database]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=15278#p15278" />
			<content type="html"><![CDATA[<p>All the user interface is subject to translation, so FA user sending out an invoice in Germany can have messages in German.&nbsp; The document printout language is defined on target basis (e.g. for invoices you can set document language per customer branch). But unfortunatelly FA does not support multi-language texts stored in database, so e.g. item names will not not be translated.<br />Janusz</p>]]></content>
			<author>
				<name><![CDATA[itronics]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=89</uri>
			</author>
			<updated>2013-01-27T10:02:26Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=15278#p15278</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: How to translate words from the database]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=15275#p15275" />
			<content type="html"><![CDATA[<p>Well if the company is &#039;internationalized&#039; they will probably use the English language, right?</p><p>At least this is my experience.</p><p>/Joe</p>]]></content>
			<author>
				<name><![CDATA[joe]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=3</uri>
			</author>
			<updated>2013-01-27T08:45:24Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=15275#p15275</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: How to translate words from the database]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=15273#p15273" />
			<content type="html"><![CDATA[<p>These data should also be &quot;internationalized&quot;. If people working in the same company from different countries are using the program, these data should also be in the language of the user. A user in Germany sending out an invoice should have the messages in German, a user in Norway in Norwegian.<br />As it is now there is only one choice.<br />To fix this you need to introduce a country table and add the different translations to the appropriate tables so that these messages can be written in the language of the user.</p>]]></content>
			<author>
				<name><![CDATA[haakon0603]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=14301</uri>
			</author>
			<updated>2013-01-27T07:39:31Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=15273#p15273</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: How to translate words from the database]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=15256#p15256" />
			<content type="html"><![CDATA[<p>Data belonging to a database should be in your natural language.</p><p>Simply translate them inside FrontAccounting.</p><p>The chart of Accounts script should have been translated from the beginning.</p><p>Joe</p>]]></content>
			<author>
				<name><![CDATA[joe]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=3</uri>
			</author>
			<updated>2013-01-25T17:27:03Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=15256#p15256</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[How to translate words from the database]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=15255#p15255" />
			<content type="html"><![CDATA[<p>Some parts of the program get the words from the database itself, and they are all in English.<br />Like each, hrs,&nbsp; Payment due within 10 days and so on.<br />Is there a way to translate these words? I have tried to&nbsp; put _() around the items in the sql query, but it does not seem to work</p>]]></content>
			<author>
				<name><![CDATA[haakon0603]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=14301</uri>
			</author>
			<updated>2013-01-25T16:51:31Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=15255#p15255</id>
		</entry>
</feed>
