-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Locale scaffolding #4246
Locale scaffolding #4246
Conversation
9da7a37
to
c8918e0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried this out locally, and it works like a charm.
I've added recommendations for updating the task description inline.
There aren't any tests for this which isn't ideal, but as it's only to help local development and the changes can be easily unchanged, I think in this case it's ok.
config/locales/no.yml
Outdated
@@ -0,0 +1,3 @@ | |||
--- | |||
no: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this one need to be in quotes? i.e. 'no':
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, interesting. Added.
lib/tasks/consolidation.rake
Outdated
# consolidation and are going to be removed. | ||
# :nocov: | ||
namespace :consolidation do | ||
desc "Copy a locale key for all locales from government-frontend to frontend" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would good to add the example usage to the description with an explanation of the example. i.e. "Add a .
to get a nested child" key etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, if you're using zsh like I am, you'll need to escape the brackets for the task to work, e.g
rake consolidation:copy_translation\[travel_advice\]
Otherwise you get an error:
zsh: no matches found: consolidation:copy_translation[travel_advice]
Perhaps this too could be added to the task description. Perhaps as a usage statement?
Apparently rake -D
show the whole description if it's over multiple lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... I'm using zsh and I didn't need to escape the brackets. I know you need to put the whole thing in speechmarks if you're running it directly in kubernetes, but that's more about the colon I think. Let me try again locally and see what's what.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated to add a bigger description, and have put the rake command in speechmarks, which is a standard way to get them to work in kubernetes and also works for zsh.
Created by making a new folder off locales (to avoid overwriting en.yml and cy.yml), then running this script (assumes you've checked out government-frontend in a directory parallel to this one). for filename in ../../../government-frontend/config/locales/*.yml; do echo -e "---\n$(basename "$filename" .yml):\n" > "new/$(basename "$filename")" done - Note that in config/locales/en.yml we've enclosed "no" in quotes. This is because in YAML no is a [reserved word](https://yaml.org/type/bool.html). We use rails_translation_manager to regenerate our locale files. When rails_translation_manager loads the YAML and interprets "no" as a bool instead of a locale, it breaks.
> i18n-tasks normalize
Example use: rake "consolidation:copy_translation[components.figure]" ... will copy everything from the government-frontend translation files under the components.figure key into all relevant translation files. Note that government-frontend must be in a sibling directory to frontend.
8ed9708
to
ba65325
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updating the Usage description ⭐
What
Tidy up the locale files, add empty files for the additional 64 locales (frontend at the moment only supports en/cy) and add a task that will allow us to copy across all translations of a specific localisation tree.
Why
https://trello.com/c/woZwSv9D/363-create-translation-scaffolding-for-frontend
How
Use rails_translation_manager / i18n-tasks where possible (but they don't support this exact use case, so some workarounds)