Jump to content

Czech localization + TextDomainHelper.module


Radek
 Share

Recommended Posts

Hi all, this is my first post here so i must tell that ProcessWire is the best CMF i know. Good work Ryan and others.

After 14 days with PW i made two sites and alpha version of czech localization package.

After hard time translating PW backend i found that i need one more tool. 

Tool which can find json files used on specific page. 

We speak about it on IRC with Soma and he made awesome new module for me TextDomainHelper.module


This module gives new posibility to Chrome PHP Debug module. In js output i can find all used strings and where are stored.

Without this tool its much more dificult to translate PW!

Example output:

textdomain:/srv/http/pw_dev_translate/wire/templates-admin/default.php Text:Admin

This module needs to have LanguageTranslator::getTranslation hookable.

Ryan, can you make it hookable please?
  • Like 6
Link to comment
Share on other sites

Hello boys and gals.

I have made little adjustments to the module to show shorter textdomain and the original and translated string.

If a text doesn't show up, there's no translation there. Only string that are _("Text") 'ded will show.

post-100-0-48486900-1358163854_thumb.png

  • Like 1
Link to comment
Share on other sites

Hello boys and gals.

I have made little adjustments to the module to show shorter textdomain and the original and translated string.

If a text doesn't show up, there's no translation there. Only string that are _("Text") 'ded will show.

attachicon.gifPastedGraphic-1.png

Nice work soma, using it alot.

Link to comment
Share on other sites

This module needs to have LanguageTranslator::getTranslation hookable.
Ryan, can you make it hookable please?

Good to see you here Radik, and thanks for your work with the localization and module. 

This is a high volume function, so I'm implementing the hook a little differently here. Can you try replacing your LanguageSupport.php file with the attached and let me know if this still works with the hook the way you need it?

LanguageTranslator.php

Also, when ready, it would be great if you'd like to add your localization and module to the modules directory at: http://modules.processwire.com/add/

Link to comment
Share on other sites

Good to see you here Radik, and thanks for your work with the localization and module. 

This is a high volume function, so I'm implementing the hook a little differently here. Can you try replacing your LanguageSupport.php file with the attached and let me know if this still works with the hook the way you need it?

attachicon.gifLanguageTranslator.php

Also, when ready, it would be great if you'd like to add your localization and module to the modules directory at: http://modules.processwire.com/add/

Hi Ryan, i tested new LanguageTranslator.php and everything works fine thanks! 

Credits for TextDomainHelper.module goes to Soma as he is author of this module. I gave him only idea.

Yes i will add czech localization to processwire.com soon, looks like its not alpha anymore ;).

Can i continuously send you somewhere my findings of missing localizations like (/processwire/access/users/ - E-MAIL ADDRESS, /processwire/access/users/ - ROLES)? Seems like they missing in PW.

One more about plurals - seems like plurals in backend need update too.

Example(modules/PagePaths.module): 

EN Singular Version(1): Updated %d path

EN Plural Version(2->): Updated %d paths

CS Singular Version (1): Aktualizována %d cesta

CS Plural Version(2-4): Aktualizovány %d cesty

CS Plural Version(5->): Aktualizováno %d cest

Link to comment
Share on other sites

Can i continuously send you somewhere my findings of missing localizations like (/processwire/access/users/ - E-MAIL ADDRESS, /processwire/access/users/ - ROLES)? Seems like they missing in PW.

Sure--though I am aware of most of them, but it would be good for me to know which ones are most important to people so that I can put those first. 

The two you mentioned are actually fields, so they are in the DB rather than a file. You can edit them by editing the 'roles' or 'email' fields. These don't appear in your fields list until you click Filters > Show System Fields. 

One more about plurals - seems like plurals in backend need update too.

Example(modules/PagePaths.module): 

Currently we only support singular and plural, and not multiple kinds of plurals. I will have to add support for this the next time we are doing upgrades to the Language Support modules. Though so far it's not clear to me how the function implementation work for this. I'm looking for gettext examples that demonstrate it. 

  • Like 1
Link to comment
Share on other sites

Sure--though I am aware of most of them, but it would be good for me to know which ones are most important to people so that I can put those first. 

The two you mentioned are actually fields, so they are in the DB rather than a file. You can edit them by editing the 'roles' or 'email' fields. These don't appear in your fields list until you click Filters > Show System Fields. 

Currently we only support singular and plural, and not multiple kinds of plurals. I will have to add support for this the next time we are doing upgrades to the Language Support modules. Though so far it's not clear to me how the function implementation work for this. I'm looking for gettext examples that demonstrate it. 

Ok, the biggest found issue - https://github.com/ryancramerdesign/ProcessWire/issues/153

And one missing translation support, that is on the eyes.

/wire/modules/Process/ProcessTemplate/ProcessTemplate.module (/setup/template/edit?id=xx)

1047:         $field->label = "May pages using this template have children?";

I know how look gettext rules "Plural-Forms: nplurals=2; plural=(n != 1);" but not much about gettext implementation, so i cant help much here.

Link to comment
Share on other sites

Ok, the biggest found issue - https://github.com/r...Wire/issues/153

I'm not sure I understand this particular issue, but will experiment. 

1047:         $field->label = "May pages using this template have children?";

Thanks, not sure how I missed that one. I have updated it, and it should appear in the source very soon. 

Link to comment
Share on other sites

I'm not sure I understand this particular issue, but will experiment. 

Easy to reproduce, i have translated strings from Inputfield.php in wire--core--inputfield-php.json

But when look on page where may display, strings are still in default en.(not translated.)

For example that string from issue 153, but there are more of them on more places.

And few others missing translations:


/wire/core/Field.php

359:             if(!$fieldgroupContext) $inputfields->head = "Input field settings";

FieldtypeText.module (/setup/field/edit?id=xx)

$f->description = '' .
                    'If you want to apply any automatic formatting to the field when it is prepared for output, select one or more text formatters above. ' .
                    'If you select more than one, drag them into the order they should be applied.';
FieldtypeTextarea.module (/setup/field/edit?id=xx)

$f->description =
                "The type of field that will be used to collect input (Textarea is the default). " .
                 "Note that if you change this and submit, the available configuration options in " .
                "the 'Inputfield Settings' section below may change.";
FieldtypeTextarea.module

$f->label = 'Inputfield Type';
   66          $f->description =
   67:             "The type of field that will be used to collect input (Textarea is the default). " .
   68              "Note that if you change this and submit, the available configuration options in " .
   69              "the 'Inputfield Settings' section below may change.";

For Soma: little weird is that TextDomainHelper.module show under this string path /wire/modules/Inputfield/InputfieldCheckbox.module but real path is /wire/core/Inputfield.php

Link to comment
Share on other sites

Radek, all the text you mentioned is now translatable. Also, the issue that caused it to miss text in Inputfield.php and Fieldtype.php should now be fixed as well (dev branch).  Please confirm when you get a chance. 

  • Like 1
Link to comment
Share on other sites

Radek, all the text you mentioned is now translatable. Also, the issue that caused it to miss text in Inputfield.php and Fieldtype.php should now be fixed as well (dev branch).  Please confirm when you get a chance. 

Thank you Ryan for great work. Issues solved and everything work fine.

Total translatable files in dev branch is 84 now. Czech localization progressing fast, i think i will have version 0.8 tommorow.

  • Like 1
Link to comment
Share on other sites

Version 0.8 finished and few other missing translations found.

/wire/modules/Fieldtype/FieldtypeDatetime.module
443:    $f->label = "Date/Time Output Format Code";
/wire/modules/Inputfield/InputfieldDatetime/InputfieldDatetime.module
255:    $f->label = "Date Input Format Code";
/wire/modules/Inputfield/InputfieldDatetime/InputfieldDatetime.module
268:    $f->label = "Time Input Format Code";
  • Like 1
Link to comment
Share on other sites

Thanks Radek, I have added these is the latest commit to dev. 

One more catch.

/wire/modules/Fieldtype/FieldtypePage.module:
  535     $select->label = 'Dereference in API as';
  536     $select->description =
  537:      "If your field will contain multiple pages, then you should select the first option (PageArray). " .
  538       "If your field only needs to contain a single page, then select one of the single Page options " .
  539       "(if you aren't sure which, select the last option).";
  540:    $select->addOption(FieldtypePage::derefAsPageArray, 'Multiple pages (PageArray)');
  541     $select->addOption(FieldtypePage::derefAsPageOrFalse, 'Single page (Page) or boolean false when none selected');
  542     $select->addOption(FieldtypePage::derefAsPageOrNullPage, 'Single page (Page) or empty page (NullPage) when none selected');

Thanks

  • Like 1
Link to comment
Share on other sites

  • 9 years later...

Hi @ryan

On 1/16/2013 at 5:01 PM, ryan said:

Currently we only support singular and plural, and not multiple kinds of plurals. I will have to add support for this the next time we are doing upgrades to the Language Support modules. Though so far it's not clear to me how the function implementation work for this. I'm looking for gettext examples that demonstrate it. 

Slovenian

"Language: sl\n"
"Plural-Forms: nplurals=4; plural=(n%100==1 ? 1 : n%100==2 ? 2 : n%100==3 || n%100==4 ? 3 : 0);\n"
msgid "%d translated message"
msgid_plural "%d translated messages"
msgstr[0] "%d prevedenih sporočil"
msgstr[1] "%d prevedeno sporočilo"
msgstr[2] "%d prevedeni sporočili"
msgstr[3] "%d prevedena sporočila"

Russian

"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
msgid "%d day ago"
msgid_plural "%d days ago"
msgstr[0] "%d день назад"
msgstr[1] "%d дня назад"
msgstr[2] "%d дней назад"

Czech (some as Russian)

msgid "Updated %d path"
msgid_plural "Updated %d paths"
msgstr[0] "Aktualizována %d cesta"
msgstr[1] "Aktualizovány %d cesty"
msgstr[2] "Aktualizováno %d cest"

Almost all Slavic languages have such plural forms. If you get support for these multiple forms, it will greatly improve the translation.

Gettext algorithms for all languages can be found here: http://docs.translatehouse.org/projects/localization-guide/en/latest/l10n/pluralforms.html

 

  • Like 2
Link to comment
Share on other sites

  • 3 weeks later...

Hi @ryan

I made a small function to help Slavic translations.

function my_decl($n, $forms){
  $modulo = $n % 10;
  $dec = $n % 100;
  return $n . ' ' . (($dec > 9 && $dec < 20) || $modulo > 4 || $modulo == 0 ? $forms[2] : ($modulo == 1 ? $forms[0] : $forms[1]));
}
    
    echo my_decl($leta, ['rok', 'roky', 'let']); // cz 
    echo my_decl($chas, ['година', 'години', 'годин']); // ukr
    echo my_decl($girls, ['девушка', 'девушки', 'девушек']); // ru

Czech version:

  • When $leta=0, it returns the string '0 let'.
  • When $leta=1, it returns the string '1 rok'.
  • When $leta=2, it returns the string '2 roky'. 
  • When $leta=30123, it returns the string '30123 roky'. 
  • When $leta=30120, it returns the string '30120 let'. 
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...