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 »
  • Internationalization and Localization (Moderators: Michał Mach, mathieu) »
  • Where to put extension .mo files?
Pages: [1]

Author Topic: Where to put extension .mo files?  (Read 1267 times)

ucHH

  • I’m new here
  • *
  • Posts: 9
  • Karma: 0
  • CiviCRM version: 4.5
  • CMS version: Drupal 7.34
  • MySQL version: 5.6
  • PHP version: 5.6.2
Where to put extension .mo files?
February 04, 2015, 03:54:36 am
I'm using CiviCRM 4.5.5 on Drupal 7.34 in German. I have a few extensions installed including com.cividesk.l10n.update, which downloads empty .mo files to e.g. /sites/default/files/civicrm/extensions/net.ourpowerbase.sumfields/l10n/de_DE/LC_MESSAGES
Apparently, those .mo files are not properly compiled (I filed an issue at https://issues.civicrm.org/jira/browse/INFRA-134). However, some extension already have compiled .mo files in their repositories. I tried to replace the empty files with the .mo files from the repositories. I hoped, this would work but even this did not change anything. So, even with proper .mo files, extensions don't get translated, while the rest of CiviCRM gets translated.
BTW, I'm using native gettext support via
Code: [Select]
define('CIVICRM_GETTEXT_NATIVE', 1); in civicrm.settings.php.
« Last Edit: February 04, 2015, 08:16:42 am by ucHH »

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: Where to put extension .mo files?
February 04, 2015, 07:15:28 am
Thanks for filing an issue, I will take a look.
CiviCamp Montréal, 29 septembre 2017 | Co-founder / consultant / turn-key CiviCRM hosting for Quebec/Canada @ SymbioTIC.coop

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: Where to put extension .mo files?
February 04, 2015, 11:18:16 am
From a first glance, it seems like most of those extensions do not have any translatable strings in them. Could you give an example of a non-translated string (and from which extension it's from)?

Although it is a bug in the 'extraction' script that it creates a .mo for extensions that do not have any translatable strings. I will continue looking into it.
CiviCamp Montréal, 29 septembre 2017 | Co-founder / consultant / turn-key CiviCRM hosting for Quebec/Canada @ SymbioTIC.coop

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: Where to put extension .mo files?
February 04, 2015, 12:23:37 pm
As mentioned in INFRA-134, it seems like l10nupdate depends on those empty files in order to track which translations were last checked. It should not otherwise have any performance impact, since the files are not loaded anyway (the extension does not have any translated strings).
CiviCamp Montréal, 29 septembre 2017 | Co-founder / consultant / turn-key CiviCRM hosting for Quebec/Canada @ SymbioTIC.coop

ucHH

  • I’m new here
  • *
  • Posts: 9
  • Karma: 0
  • CiviCRM version: 4.5
  • CMS version: Drupal 7.34
  • MySQL version: 5.6
  • PHP version: 5.6.2
Re: Where to put extension .mo files?
February 05, 2015, 03:21:25 am
Thanks for your answers. Well, have a look at the reviewed extension "summary fields" (https://civicrm.org/extensions/summary-fields). It includes a .pot file (https://github.com/progressivetech/net.ourpowerbase.sumfields/blob/master/l10n/sumfields.pot) that has been generated by create-pot-files-extensions.sh (see https://github.com/progressivetech/net.ourpowerbase.sumfields/blob/master/l10n/update_pot.sh). Thus, the extension contains translatable strings. As far as I understand the civicrm-l10n-extensions mechanism, it should generate the very same .pot file. Than it should upload e.g. https://github.com/progressivetech/net.ourpowerbase.sumfields/blob/master/l10n/sumfields_de_DE.po to Transifex, so it can generate the .mo file. That's why I filled the issue about empty .pot files. I might be failing in extracting the strings for some reason. Or do you the think, the extension itself isn't structured properly?
Apart from that, I still have the issue that extensions don't get translated, even if I manually put the .mo files in the corresponding directories. Any idea on that?
« Last Edit: February 05, 2015, 03:24:03 am by ucHH »

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: Where to put extension .mo files?
February 05, 2015, 05:44:20 am
Aha, ok, there are two issues:

1- There are strings that are not correctly using ts() and it is causing gettext to fail. For example:

Code: [Select]
      $session->setStatus(ts("Summary Fields is not particularly useful if
        CiviContribute and CiviEvent are both disabled. Try enabling at least
        one."));

This generates:

Code: [Select]
#: CRM/Sumfields/Form/SumFields.php
msgid "Summary Fields is not particularly useful if
        CiviContribute and CiviEvent are both disabled. Try enabling at least
        one."
msgstr ""

Normally I would just recommend to write the setStatus() on one big line. I can understand that for the extension author, this is a coding style annoyance, and probably their code editor anyway formatted it that way. It's more a bug in the extraction scripts.

2- the author of the extension is not using the 'domain' argument for ts(), to specify that the string is part of the extension. CiviCRM doesn't really have a way of knowing that ts() is being called from the extension.

It needs to use the following syntax:

Code: [Select]
ts('Hello, %1', array(1 => $name, 'domain' => 'net.ourpowerbase.sumfields'));

Alternatively, until they release a next version, you can merge the .mo files:

Code: [Select]
$ msgunfmt civicrm/l10n/de_DE/civicrm.mo -o /tmp/civicrm.po
$ msgcat --use-first /tmp/civicrm.po  /path/to/sumfields/de.po  -o civicrm/l10n/de_DE/civicrm.mo
CiviCamp Montréal, 29 septembre 2017 | Co-founder / consultant / turn-key CiviCRM hosting for Quebec/Canada @ SymbioTIC.coop

ucHH

  • I’m new here
  • *
  • Posts: 9
  • Karma: 0
  • CiviCRM version: 4.5
  • CMS version: Drupal 7.34
  • MySQL version: 5.6
  • PHP version: 5.6.2
Re: Where to put extension .mo files?
February 05, 2015, 07:17:43 am
Ok, does this mean that all extension translations have to be merged in the civicrm.mo file and the extensions cannot use their own separate .mo file? Because the sumfields extension comes with a .mo file. And com.cividesk.l10n.update also downloads seperate .mo files for extensions. That's why I tried replacing those automatically downloaded .mo files with the proper ones, that I downloaded manually. So all other .mo files besides civicrm.mo are ignored?

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: Where to put extension .mo files?
February 05, 2015, 07:42:04 am
I sent a pull-request:
https://github.com/progressivetech/net.ourpowerbase.sumfields/pull/2

And did a temporary fix in order to send the translations to Transifex:
https://www.transifex.com/projects/p/civicrm_extensions/resource/sumfields/

@ucHH: normally, civicrm.mo is core only, and each extension has their .mo file. However, for this to work, extensions have to use the syntax that specifies the domain: http://wiki.civicrm.org/confluence/display/CRMDOC/Extension+translation

The merging of .mo files is a workaround until most extensions are fixed. There isn't really a mechanism/policy on this, it should be part of the process when extensions are vetted as "ready for automatic distribution".
CiviCamp Montréal, 29 septembre 2017 | Co-founder / consultant / turn-key CiviCRM hosting for Quebec/Canada @ SymbioTIC.coop

ucHH

  • I’m new here
  • *
  • Posts: 9
  • Karma: 0
  • CiviCRM version: 4.5
  • CMS version: Drupal 7.34
  • MySQL version: 5.6
  • PHP version: 5.6.2
Re: Where to put extension .mo files?
February 05, 2015, 08:42:40 am
Great! Thanks, for all your help! Will do the merge  :)

ucHH

  • I’m new here
  • *
  • Posts: 9
  • Karma: 0
  • CiviCRM version: 4.5
  • CMS version: Drupal 7.34
  • MySQL version: 5.6
  • PHP version: 5.6.2
Re: Where to put extension .mo files?
February 05, 2015, 09:16:49 am
On more question: Is there an easy way to import the german .po file (https://github.com/progressivetech/net.ourpowerbase.sumfields/blob/master/l10n/sumfields_de_DE.po) to https://www.transifex.com/projects/p/civicrm_extensions/resource/sumfields/? Do I have to join the translation group to do so?

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: Where to put extension .mo files?
February 05, 2015, 10:17:10 am
You need to join the German translation team, then you can upload a translated .po file, or translate using the web interface.

I had not done it in a while, so I went ahead and tried uploading the po file. It seems to have translated only 29 strings out of 77, but checking the sumfields_de_DE.po from the sumfields repository, it does seem to only have a subset of the strings.
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 »
  • Internationalization and Localization (Moderators: Michał Mach, mathieu) »
  • Where to put extension .mo files?

This forum was archived on 2017-11-26.