i18n-translators-tools icon indicating copy to clipboard operation
i18n-translators-tools copied to clipboard

Doesn't work if file is not named after locale

Open Silex opened this issue 10 years ago • 8 comments

Hello,

  • i18n-translate en.yml en.po works
  • i18n-translate user.yml user.po doesn't work

Any idea why?

Silex avatar Nov 02 '15 14:11 Silex

Can you provide user.yml file?

pejuko avatar Nov 02 '15 16:11 pejuko

Here it is:

---
en:
  user:
    cancel_account: cancel account
    mailer:
      confirmation_instructions:
        confirm_account: Confirm account
        message: Message
        welcome: Welcome
    sign_in: Sign in
    sign_out: Logout
    sign_up: Sign up
    user: User

Silex avatar Nov 02 '15 16:11 Silex

i18n-translators-tools is designed to work with directory structure and locales are determined from the file names, so it expects something like user/en.yml. Unfortunately I don't have much time to improve this tool to accept arbitrary conversions right now. If you provide reasonable patch that will keep compatibility I'm going to accept it.

pejuko avatar Nov 03 '15 08:11 pejuko

Can you elaborate on why it needs the file name at all? I mean, the first key in all of these files is the locale...

Silex avatar Nov 03 '15 08:11 Silex

Not all types are having locales information within. e.g java properties files does not have, so I needed to keep the information somewhere. If the locale information is in the file name you can convert properties to yaml successfully.

pejuko avatar Nov 03 '15 09:11 pejuko

Ah, I see.

Is there a way to tell i18n-translate which locale we are talking about?

Something like i18n-translate -l en user.yml user.po would be nice.

Silex avatar Nov 03 '15 10:11 Silex

I'm leaving this open, so I'll get back in to this in the future. For now you have to rename the file to en.yml and after conversion rename the po file back to user.po. Sorry for the inconvenience.

pejuko avatar Nov 03 '15 13:11 pejuko

Alright, I'll see if I can find some time to make a PR. Thanks for the infos.

Silex avatar Nov 03 '15 13:11 Silex