Skip to content
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

Import translations and sync locales #2615

Merged
merged 12 commits into from
Dec 2, 2021
Merged

Import translations and sync locales #2615

merged 12 commits into from
Dec 2, 2021

Conversation

1pretz1
Copy link
Contributor

@1pretz1 1pretz1 commented Nov 29, 2021

Imports translations and sync locales.

More info in the commits ->

Trello:
https://trello.com/c/Xz78vNR4/2757-import-newly-sourced-translations-into-locale-files-5

⚠️ This repo is Continuously Deployed: make sure you follow the guidance ⚠️

@govuk-ci govuk-ci temporarily deployed to govuk-collec-import-tra-kylimv November 29, 2021 17:05 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-collec-import-tra-kylimv November 30, 2021 12:23 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-collec-import-tra-kylimv November 30, 2021 12:55 Inactive
@1pretz1 1pretz1 force-pushed the import-translations branch from a6944bb to 4169572 Compare November 30, 2021 13:05
@govuk-ci govuk-ci temporarily deployed to govuk-collec-import-tra-kylimv November 30, 2021 13:05 Inactive
`bundle exec rake translation:import:all['dir/to/csvs.csv, true']`
The about page was previously hard coded for the English and Welsh link
only. This commit adds support for the rest of the languages.
@1pretz1 1pretz1 force-pushed the import-translations branch from 4169572 to 6bb97d9 Compare November 30, 2021 16:52
@govuk-ci govuk-ci temporarily deployed to govuk-collec-import-tra-kylimv November 30, 2021 16:52 Inactive
Copy link
Contributor

@ChrisBAshton ChrisBAshton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking great! Some very minor suggestions below:

config/i18n-tasks.yml Show resolved Hide resolved
config/i18n-tasks.yml Show resolved Hide resolved
config/locales/be/organisations.yml Show resolved Hide resolved
config/locales/ar/shared.yml Show resolved Hide resolved
@@ -7,6 +7,6 @@ bn:
title: GOV.UK ব্রাউজ করুন
get_emails: এই বিষয়ের জন্য ইমেইল নিন
language_direction: ltr
language_name: ইংরেজি
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well spotted!

Collections uses language subdirectories to organise it's locales. We
have to add custom config which tells i18n-tasks how the keys are
organised.

The write config: `['{:}.*', 'config/locales/\1.%{locale}.yml'` was
copied from the i18n-tasks documentation which tells i18n-tasks to write
every top-level key namespace to its own file. For example,
'fr.organisation.parent.key' would be added to the French directory
('fr') and the top level key would become the filename
('organisation.yml'). This config complies with the current Collections
formatting.

[1]: https://github.com/glebm/i18n-tasks/tree/1b9e0465e984df8f7890f620b0bbb6646d40d77f#pattern-router
This list of 'ignore_unused' keys tells i18n-tasks which keys to ignore
when it attempts to remove unused keys from the codebase. The keys in
the list are used, but are called upon dynamically (string interpolation
etc), for example: 'schema.#{doc_type}.#{count}'. I18n-tasks default
scanners can't detect these and so we need to add an ignore list.
bundle exec i18n-tasks remove-unused
Safeguard against raw HTML being rendered in the application. See [1]
for more information.

[1]: https://guides.rubyonrails.org/i18n.html#using-safe-html-translations
After the translations import, the language direction for these
languages was updated to LTR which is incorrect. The correct direction
for these languades were sourced from the translators themselves and
verified using Google.
`language_name` has been incorrectly translated to English, in various
languages, rather than the actual languages name. These translations
have been copied from Whitehall's locale keys.
These were missed from the original import as the translations supplier
renamed the CSV column 'translation' to 'source'. This reverts the name
change and imports the CSV.
bundle exec rake translation:add_missing
@1pretz1 1pretz1 force-pushed the import-translations branch from 6bb97d9 to 6a504bc Compare December 2, 2021 12:49
@govuk-ci govuk-ci temporarily deployed to govuk-collec-import-tra-kylimv December 2, 2021 12:50 Inactive
@1pretz1
Copy link
Contributor Author

1pretz1 commented Dec 2, 2021

Cheers for the review @ChrisBAshton. I've addressed your comments and thanks for making them as my commit messages were quite non-descriptive!

@1pretz1 1pretz1 requested a review from ChrisBAshton December 2, 2021 12:57
Copy link
Contributor

@ChrisBAshton ChrisBAshton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff - thanks Peter ⭐

@1pretz1 1pretz1 merged commit dcf58dd into main Dec 2, 2021
@1pretz1 1pretz1 deleted the import-translations branch December 2, 2021 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants