<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[FrontAccounting forum — How to translate words from the database]]></title>
		<link>https://frontaccounting.com/punbb/viewtopic.php?id=3798</link>
		<atom:link href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=3798&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in How to translate words from the database.]]></description>
		<lastBuildDate>Wed, 30 Jan 2013 11:27:08 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: How to translate words from the database]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=15382#p15382</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (haakon0603)]]></author>
			<pubDate>Wed, 30 Jan 2013 11:27:08 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=15382#p15382</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to translate words from the database]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=15358#p15358</link>
			<description><![CDATA[<p>Placed content in <a href="https://frontaccounting.com/fawiki/index.php?n=Devel.TranslationOfStringsInDatabase"><strong>Wiki</strong></a></p>]]></description>
			<author><![CDATA[null@example.com (apmuthu)]]></author>
			<pubDate>Tue, 29 Jan 2013 02:25:57 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=15358#p15358</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to translate words from the database]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=15357#p15357</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (apmuthu)]]></author>
			<pubDate>Tue, 29 Jan 2013 01:48:54 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=15357#p15357</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to translate words from the database]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=15338#p15338</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (haakon0603)]]></author>
			<pubDate>Mon, 28 Jan 2013 16:20:37 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=15338#p15338</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to translate words from the database]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=15305#p15305</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (itronics)]]></author>
			<pubDate>Sun, 27 Jan 2013 17:53:23 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=15305#p15305</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to translate words from the database]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=15304#p15304</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (haakon0603)]]></author>
			<pubDate>Sun, 27 Jan 2013 16:41:55 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=15304#p15304</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to translate words from the database]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=15297#p15297</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (apmuthu)]]></author>
			<pubDate>Sun, 27 Jan 2013 13:59:52 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=15297#p15297</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to translate words from the database]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=15278#p15278</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (itronics)]]></author>
			<pubDate>Sun, 27 Jan 2013 10:02:26 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=15278#p15278</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to translate words from the database]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=15275#p15275</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (joe)]]></author>
			<pubDate>Sun, 27 Jan 2013 08:45:24 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=15275#p15275</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to translate words from the database]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=15273#p15273</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (haakon0603)]]></author>
			<pubDate>Sun, 27 Jan 2013 07:39:31 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=15273#p15273</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to translate words from the database]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=15256#p15256</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (joe)]]></author>
			<pubDate>Fri, 25 Jan 2013 17:27:03 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=15256#p15256</guid>
		</item>
		<item>
			<title><![CDATA[How to translate words from the database]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=15255#p15255</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (haakon0603)]]></author>
			<pubDate>Fri, 25 Jan 2013 16:51:31 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=15255#p15255</guid>
		</item>
	</channel>
</rss>
