Translation file technical question on location/usage

Events happening in the community are now at Drupal community events on www.drupal.org.
Anonymous's picture

Hi all! I have a general question on how translation files (.po files) are used and work.

I have this code in a Ubercart module (ubercart/uc_store/uc_store.module) that I have been trying to get translated:

'first_name' => t('First name'),

I imported the l.d.o translation files and found the translation in ubercart/translations/general.ja.po

#: uc_store.admin.inc:233 uc_store.module:708;1177
msgid "First name"
msgstr "名"

This looks like it should work but it doesn't.

I had to create a separate translation file for the sub-module under ubercart/uc_store/uc_store.module/translations/uc_store.ja.po

So my questions are:

1- Why wasn't the translation picked up from the general.ja.po file? When is this file actually used?
2- I found that .po file for a module must be in a separate module_name/translations directory. How does it apply to sub-module? I.e. the module here is Ubercart, the sub module is uc_store ... so why are there translations for it (and many other sub-modules) in the ubercart/translations/general.ja.po file?

Thanks!

Comments

My Bad

Dokuro's picture

@totsubo

I know we talked online about this and your got it all worked out. But just to update people here, I didn't really give much direction for the translations and how to deal with them when I posted them.

I will try to work up a write up on this. I also just put the translation files in directories but only to keep track of them, not to how they should be uploaded. I didn't put them in the translations directory like I should have.

So sorry, this is my fault. I will rework them.

A quick way to use the files. Go to /admin/build/translate/import and import them there.

I want to run through all the ways to add translations besides the way I do them normally before I post more directions.

Regards,

Shaun

Thanks Shaun. Actually this

totsubo's picture

Thanks Shaun.

Actually this post was to ask a more general question about .po files.

Basically:

1- What is the correct location for a module's translation/general.ja.po file to be automatically imported by Drupal when one uses the translation interface to import all translation (using admin/build/translate/import/package). I'm assuming it's possible but if it isn't then that answers my questions and the only way to get it into Drupal is to use the file import method as you decribe

2- If you have a module called A and a sub module in A called B, where should the translation file for B be located to get imported automatically? Should they be in A/translations/b.ja.po or in A/B/translations/b.ja.po?

Not sure if this will answer

Antoine Lafontaine's picture

Not sure if this will answer your question, but

  1. translation files are only imported when you install a module (or install drupal), if you want to update your already installed translation (or translate an untranslated module at the time you installed it) you need to use Shaun's import technique.

  2. all translation files should be in the module/translation folder. I think applies for all "sub-modules" contained in a module... Might be wrong on this though.

And don't forget ...

totsubo's picture

I've just spent 2 hours trying to figure out why my Ubercart address fields were not being translated even though I loaded, and kept re-loaded, the correct .po files. So just in case someone else goes through this here's a tip:

  • reset the address fields to their defaults (admin/store/settings/checkout/edit/fields)

For some reason if you change these it may eventually cause your address field translations to be lost. You can keep trying to reload the .po file but it won't work. Trust me, I've just spent the last 2 hours re-importing, deleting, overwriting ... various .po files trying to figure out why my address fields weren't translated.

What grief ... I'm just happy it's over.

Don't work for me

sakiland's picture

This is not work for me. I must change code like on http://www.ubercart.org/forum/internationalization/11999/my_solution_add...
I know this is not solution, but I can't find another one. In same function (theme_address_pane($form)), I also change this

if (substr($field, -7) == 'street1') {
    $title = uc_get_field_name('street') .':';

to this
if (substr($field, -7) == 'street1') {
    $trans = t(uc_get_field_name('street'));
    $title =  $trans . ':';
}

Worked for me. Though it's a

visnevskiscom's picture

Worked for me. Though it's a bit limiting not to be able to save field config :(
Thanks for tip!

日本 コミュニティ: Drupal Japan User Group

Group organizers

Group categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: