CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Discussion »
  • Extensions (Moderators: mathieu, totten, kasiawaka) »
  • How translate extension
Pages: [1]

Author Topic: How translate extension  (Read 2840 times)

rubofvil

  • I’m new here
  • *
  • Posts: 23
  • Karma: 1
  • CiviCRM version: 4.2.7
  • CMS version: Drupal 7
  • MySQL version: mysql 5.1
  • PHP version: php 5.2
How translate extension
April 18, 2013, 02:05:25 am
I need any information about how translate one extension of civicrm.
I know the function "ts" to make the texts translatable (http://wiki.civicrm.org/confluence/display/CRMDOC42/Internationalisation+for+Developers)

But i need the way to use po files or other method to include translations. Or any leads to follow. Thanks.

mathieu

  • Administrator
  • Ask me questions
  • *****
  • Posts: 620
  • Karma: 36
    • Work
  • CiviCRM version: 4.7
  • CMS version: Drupal
  • MySQL version: MariaDB 10
  • PHP version: 7
Re: How translate extension
April 18, 2013, 07:22:21 am
Currently it is not possible to easily translate extensions. Joe Murray had posted a good blog post about this a while back on what kind of workflow we could use: http://civicrm.org/blogs/joe-murray/translations-extensions

I was hoping to work on this during the code sprints following the SF 2013 CiviCon (http://sf2013.civicrm.org/).

In short:

* Check whether we can bind multiple domains, so that we can load the .mo translation file of each extension. (ex: http://stackoverflow.com/questions/9668471/use-multiple-domains-in-gettext-in-a-php-application)

In the mean time, some workarounds, not ideal:

* create your own .po file, and merge it with the civicrm.mo file:

msgunfmt civicrm.mo -o civicrm.po
msgcat --use-first *.po | msgfmt -o civicrm.mo -

* or, use a custom translation handler (it can be set in Admin -> Localisation -> Language). You could try to bind a new gettext domain from there, until it becomes available in core.

If you're not familiar with native gettext, it gives a very good performance improvement (over 20%), but your host needs to support it:
http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Localisation#CiviCRMLocalisation-Usingnativegettextsupport/setlocale

Mathieu (bgm on #civicrm)
CiviCamp Montréal, 29 septembre 2017 | Co-founder / consultant / turn-key CiviCRM hosting for Quebec/Canada @ SymbioTIC.coop

rubofvil

  • I’m new here
  • *
  • Posts: 23
  • Karma: 1
  • CiviCRM version: 4.2.7
  • CMS version: Drupal 7
  • MySQL version: mysql 5.1
  • PHP version: php 5.2
Re: How translate extension
April 19, 2013, 03:05:13 am
Very good answer  :D

I investigate this posibles solutions, when  i will apply one i give feedback(in this post).

I'm not going CiviCon , to far for me.  I hope we will see webcast.

Thanks!!

« Last Edit: April 19, 2013, 03:07:17 am by rubofvil »

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: How translate extension
April 22, 2013, 01:27:34 pm
BGM: This would be a great project for the sprints. Joe will be there too.
Try asking your question on the new CiviCRM help site.

mathieu

  • Administrator
  • Ask me questions
  • *****
  • Posts: 620
  • Karma: 36
    • Work
  • CiviCRM version: 4.7
  • CMS version: Drupal
  • MySQL version: MariaDB 10
  • PHP version: 7
Re: How translate extension
April 28, 2013, 11:10:09 pm
I started work on this:
http://issues.civicrm.org/jira/browse/CRM-12446

With the patch done so far, it would be possible to test it already, if you can create the po/mo file manually.
https://github.com/mlutfy/civicrm-core/commit/eab655a61d56c35cedb0ace96b4b6f615b55f6b0
CiviCamp Montréal, 29 septembre 2017 | Co-founder / consultant / turn-key CiviCRM hosting for Quebec/Canada @ SymbioTIC.coop

rubofvil

  • I’m new here
  • *
  • Posts: 23
  • Karma: 1
  • CiviCRM version: 4.2.7
  • CMS version: Drupal 7
  • MySQL version: mysql 5.1
  • PHP version: php 5.2
Re: How translate extension
January 29, 2014, 07:06:10 am
Finally I used the option

* create your own .po file, and merge it with the civicrm.mo file

I put the steps that work for me.
1. Execute the script to generate the "po" from the extension (https://github.com/civicrm/l10n/blob/master/bin/create-pot-files-extensions.sh , that you did it  :) )
../l10n/bin/./create-pot-files-extensions.sh "extension" . "extension"/
2. Convert pot to po with POEditor(one option)
3. Extract de civicrm.po in folder (l10n / po / es_ES  (extracting the spanish)) with: "msgunfmt civicrm.mo -o civicrm.po"
4. Move the po generate in step 2 to the folder(l10n / po / es_ES)
5. Generate the mo: msgcat --use-first *.po | msgfmt -o civicrm.mo -
6. Change the language from CiviCRM

Thanks!

mathieu

  • Administrator
  • Ask me questions
  • *****
  • Posts: 620
  • Karma: 36
    • Work
  • CiviCRM version: 4.7
  • CMS version: Drupal
  • MySQL version: MariaDB 10
  • PHP version: 7
Re: How translate extension
January 29, 2014, 07:31:41 am
Thanks for sharing!

For reference, there is some documentation here:
http://wiki.civicrm.org/confluence/display/CRMDOC/Extension+translation

.. but it really needs more documentation, especially regarding "ts()" usage, since we are stalled on CRM-13580 (http://issues.civicrm.org/jira/browse/CRM-13580).

Mathieu
CiviCamp Montréal, 29 septembre 2017 | Co-founder / consultant / turn-key CiviCRM hosting for Quebec/Canada @ SymbioTIC.coop

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Discussion »
  • Extensions (Moderators: mathieu, totten, kasiawaka) »
  • How translate extension

This forum was archived on 2017-11-26.