Topic: Small bug for gettext translations - locations.php

'Inventory Locations' and also 'Fixed Assets Locations' is not being translated; looking at file locations.php I believe the relevant code is below:-

File: \inventory\manage\locations.php
21: if (isset($_GET['FixedAsset'])) {
22:     $help_context = "Fixed Assets Locations";
23:     $_POST['fixed_asset'] = 1;
24: } else
25:     $help_context = "Inventory Locations";

I cannot see where gettext picks up the translation? There's no '_' underscore?

Shouldn't it be something like:-

File: \inventory\manage\locations.php
21: if (isset($_GET['FixedAsset'])) {
22:     page(_($help_context = "Fixed Assets Locations"));
23:     $_POST['fixed_asset'] = 1;
24: } else
25:     page(_($help_context = "Inventory Locations"));

I have not tested this

The FrontAccounting Wiki(Manual, examples, tips, setup info, links to accounting sites, etc) https://frontaccounting.com/fawiki/

2 (edited by poncho1234 10/29/2017 09:20:21 pm)

Re: Small bug for gettext translations - locations.php

Well that didn't work sad

Also in the .po file

Inventory Locations Exists
but
Fixed Assets Locations does not.

may have more time tomorrow..

The FrontAccounting Wiki(Manual, examples, tips, setup info, links to accounting sites, etc) https://frontaccounting.com/fawiki/

Re: Small bug for gettext translations - locations.php

The ,po file should then be compiled into a .mo file which is what the gettext engine will lookup. If any string does not exist in the translations files then the source string will be used. All translations will generally get updated during the release phase. Compare the empty.po file with the one you have for your language and update as necessary. Alternatively code and collect at Transifex.

Re: Small bug for gettext translations - locations.php

Maybe when the PO file updates strings from source it finds all _() functions and put whatever in it to be translated, may be at that time $help_context is undefined so it will not end up to PO file.

So we should not put a variable to gettext function.
I'm not sure this analyse is right but if change code as follow it will work.

if (isset($_GET['FixedAsset'])) {
    $help_context = _("Fixed Assets Locations");
    $_POST['fixed_asset'] = 1;
} else
    $help_context = _("Inventory Locations");

page($help_context);
Phuong

Re: Small bug for gettext translations - locations.php

Yes, variable assignment is not acceptable inside the gettext function call since it is checked for presence in the compiled .mo file if available and else the string is returned verbatim if valid.

Re: Small bug for gettext translations - locations.php

Do you want me to put this on mantis?

The FrontAccounting Wiki(Manual, examples, tips, setup info, links to accounting sites, etc) https://frontaccounting.com/fawiki/

Re: Small bug for gettext translations - locations.php

But practically all usage of $help_context variable are inside the gettext.
See sales/manage/sales_areas.php:

page(_($help_context = "Sales Areas"));

Normal assignment of strings to a variable and then using it in gettext is what is used in locations.php:

page(_($help_context));

Re: Small bug for gettext translations - locations.php

The bug is 'Inventory Locations' and also 'Fixed Assets Locations' are not being translated in their relevant screens

The FrontAccounting Wiki(Manual, examples, tips, setup info, links to accounting sites, etc) https://frontaccounting.com/fawiki/

Re: Small bug for gettext translations - locations.php

The translations will be available when the lang/new_language_template/LC_MESSAGES/empty.po is refreshed in the next release. In the meanwhile you are free to change your .po file and compile it into a .mo file and use it.

Re: Small bug for gettext translations - locations.php

apmuthu, there is a bug in locations.php, please load another language go to:-

/inventory/manage/locations.php?
And you will see that the page title 'Inventory Locations' has not been translated

then go to:-
/inventory/manage/locations.php?FixedAsset=1
And you will see that the page title 'Fixed Assets Locations' has not been translated

Where do these page titles come from? The only place in FA that lists them is locations.php

The FrontAccounting Wiki(Manual, examples, tips, setup info, links to accounting sites, etc) https://frontaccounting.com/fawiki/

Re: Small bug for gettext translations - locations.php

apmuthu, as previously stated the exact string 'Inventory Locations' exists in the po file with its translation.

the exact string 'Fixed Assets Locations' does not exist in the po file therefore would not be translated anyway.

I am unable to attach screenshots

The FrontAccounting Wiki(Manual, examples, tips, setup info, links to accounting sites, etc) https://frontaccounting.com/fawiki/

Re: Small bug for gettext translations - locations.php

@apmuthu I've finally understood what you were saying..you're right. My apologies for any confusion.

The FrontAccounting Wiki(Manual, examples, tips, setup info, links to accounting sites, etc) https://frontaccounting.com/fawiki/