0

I can't find a way to translate the fields labels for the Profile 2 fields. I have activated the Profile 2 translation module, but I don't want to translate fields of the entity, I just want to show the labels translated in the user page and the user edit form.

Does anyone know how to do it?

0

EDIT: the following description describes the steps for Drupal 8, but they are similar for Drupal 7:


You need the potx module to extract a translation template which you can translate. Unfortunately there isn't an official Drupal 8 release available, but you can use this github fork, which works fine for my needs.

Here is a short procedure to handle translations of my modules:

1. extent your module with the Interface Translation Properties (only Drupal 8)

Example my_module.info.yml:

name: My Module
description: ''
type: module
core: 8.x

'interface translation project': my_module
'interface translation server pattern': modules/my_module/translations/%language.po

Now your module is available for the locale module and translation can be handled with drush locale-check resp. drush locale-update.

2. create a subfolder for your translations

In the subfolder ./modules/my_module/translations I put the generated template and the *.po files. Fore more information have a look at the documentation on drupal.org.

3. create your template

I'm using drush to create the template. The best way for me is the creation with

drush potx single --folder=modules/my_module/ --api=8

It generates a general.pot file at the root directory of your Drupal installation. I move it into the translation folder but it's not necessary.

4. create your translation

To create a translation I'm using Poedit as editor. You can create different language files from the general.pot template. The free version of Poedit is quiet useful for editing *.po files. Save your language files in the translation folder.

5. import the translations

Run the following commands to import the translations:

drush locale-check && drush locale-update

And clear the cache:

drush cr

That's it ;)

2
  • Oh sorry, I forgot to mention it is a Drupal 7 installation.
    – jmzea
    May 19 '17 at 13:58
  • A sorry but then the procedure is similar. Then you can use the official potx module.
    – RWAM
    May 19 '17 at 14:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.