i18n-tasks
i18n-tasks copied to clipboard
Recursively translating yaml's with lists does not work
What an incredibly useful gem! Thank you for building/maintaining it! 👏
I have a somewhat complex translation yaml schema, which includes lists/sequences. Consider the following simple example:
en:
test:
one: Will this translate?
two:
- title: How about this?
body: Or this?
three:
four:
- title: How about this level?
body: And this?
five:
six: This translates
seven:
eight: And this does as well
Then, when running i18n-tasks translate-missing
, I receive this (alphabetized for simplicity):
de:
test:
one: Wird das übersetzt?
two:
- title: How about this?
body: Or this?
three:
four:
- title: How about this level?
body: And this?
five:
seven:
eight: Und dies auch
six: Dies übersetzt
Is there a mechanism for auto-translating all these keys, including those with a -
dash prefix? Am I missing something? Can I force the gem to recognize this structure?
Thanks for all you do!
FWIW, I also tried with various []
and {}
:
en:
test:
one: Will this translate?
two: {
title: How about this?,
body: Or this?
}
three:
four: {
title: How about this level?,
body: And this?
}
five:
six: This translates
seven:
eight: And this does as well
nine: [
{
title: The title,
body: A body,
},
{
title: Another title,
body: Another body,
},
]
to
de:
test:
one: Wird das übersetzt?
two:
body: Oder dieses?
title: Wie wäre es damit?
three:
four:
body: Und das?
title: Wie wäre es mit diesem Niveau?
five:
seven:
eight: Und dies auch
nine:
- title: The title
body: A body
- title: Another title
body: Another body
six: Dies übersetzt
Which is obviously closer, but still can't handle multiple list items.
And after even further testing, the following does work:
en:
test:
- Translate this
- Then this
- And after, this
Properly translates to:
de:
test:
- Übersetze das
- Dann das
- Und danach das
So naturally, I tried:
en:
test:
- {
item: The first item,
title: The first title
}
- {
item: the second thing,
title: the second title
}
And got 😩
de:
test:
- item: The first item
title: The first title
- item: the second thing
title: the second title
The translator only handles arrays and strings at the moment
If you'd like to attempt a fix by adding Hash support, the code is here
https://github.com/glebm/i18n-tasks/blob/a2adc3104e87a2b58a09c3e416f5e1151c4c7aca/lib/i18n/tasks/translators/base_translator.rb#L64-L94