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

Adds locale to the locale kebab-case warnings #3951

Merged
merged 2 commits into from Mar 24, 2024

Conversation

obulat
Copy link
Contributor

@obulat obulat commented Mar 21, 2024

Fixes

Fixes #3938 by @sarayourfriend

Description

This PR adds the locale to the warnings about kebab-cased locale keys.

The locale files contain strings with keys that can be used, for instance, to insert links into them:

license: "{readMore} about this license. gets converted to something like <a href="linkURL">read more</a> about this license

The keys like readMore were first in kebab-case. Kebab-cased keys are invalid in the latest versions of Vue i18n, so we converted them to camelCase. However, converting the keys in GlotPress is not easy and takes time. To account for that and make the translations usable, #2433 added a function that converts kebab-cased keys to camelCase. It also adds a warning to keep track if we still have some kebab-cased keys. You can see them when you run just frontend/i18n

The warning only had the key name. This PR adds the locale to the warning to make it possible to locate the key better:

bg locale kebab-cased key "marked-licensed" converted to camelCase.
bg locale kebab-cased key "view-legal" converted to camelCase.
bg locale kebab-cased key "terms-copy" converted to camelCase.
bg locale kebab-cased key "creator-name" converted to camelCase.
bg locale kebab-cased key "creative-commons" converted to camelCase.
bg locale kebab-cased key "read-more" converted to camelCase.
bg locale kebab-cased key "feat-name" converted to camelCase.
bg locale kebab-cased key "feat-state" converted to camelCase.
bg locale kebab-cased key "link-api" converted to camelCase.
bg locale kebab-cased key "single-name" converted to camelCase.
bg locale kebab-cased key "making-wordpress" converted to camelCase.
ja locale kebab-cased key "marked-licensed" converted to camelCase.
ja locale kebab-cased key "view-legal" converted to camelCase.
ja locale kebab-cased key "single-name" converted to camelCase.
da locale kebab-cased key "creative-commons" converted to camelCase.
Successfully saved 199 translations.

Testing Instructions

Run just frontend/i18n and see that the warnings have locales.

Checklist

  • My pull request has a descriptive title (not a vague title likeUpdate index.md).
  • My pull request targets the default branch of the repository (main) or a parent feature branch.
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added or updated tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no visible errors.
  • I ran the DAG documentation generator (if applicable).

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@obulat obulat requested a review from a team as a code owner March 21, 2024 17:18
Signed-off-by: Olga Bulat <obulat@gmail.com>
@openverse-bot openverse-bot added 🟧 priority: high Stalls work on the project or its dependents 🛠 goal: fix Bug fix 🕹 aspect: interface Concerns end-users' experience with the software 🚦 status: awaiting triage Has not been triaged & therefore, not ready for work labels Mar 21, 2024
@github-actions github-actions bot added the 🧱 stack: frontend Related to the Nuxt frontend label Mar 21, 2024
@obulat obulat force-pushed the add/locale-to-kebab-case-notice branch from ad07e52 to b50b2ad Compare March 21, 2024 17:19
@AetherUnbound AetherUnbound removed the 🚦 status: awaiting triage Has not been triaged & therefore, not ready for work label Mar 21, 2024
@AetherUnbound
Copy link
Contributor

@obulat I get the following when I try to run the testing command you've supplied:

$ j frontend/i18n
error: Justfile does not contain recipe `i18n`.

j frontend/run i18n does appear to run the internationalization steps though

Copy link
Contributor

@AetherUnbound AetherUnbound left a comment

Choose a reason for hiding this comment

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

Changeset looks good and the command runs as expected locally 🚀

Copy link
Contributor

@sarayourfriend sarayourfriend left a comment

Choose a reason for hiding this comment

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

LGTM. I wonder if we even need a log-per-line. If we are able to automatically convert them without issue, we could have a single log at the end with a summary "Automatically fixed x kebab-case keys to camel case", but just a nit-pick. Reducing the logging would make this look less like an error and more like an "here's some info" log.

Copy link
Member

@dhruvkb dhruvkb left a comment

Choose a reason for hiding this comment

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

👍 The information about the locale raising the warning is good to have!

frontend/src/locales/scripts/utils.js Outdated Show resolved Hide resolved
Signed-off-by: Olga Bulat <obulat@gmail.com>
@obulat
Copy link
Contributor Author

obulat commented Mar 23, 2024

LGTM. I wonder if we even need a log-per-line. If we are able to automatically convert them without issue, we could have a single log at the end with a summary "Automatically fixed x kebab-case keys to camel case", but just a nit-pick. Reducing the logging would make this look less like an error and more like an "here's some info" log.

I refactored this code to log a single line by default. Also, if you run just frontend/run i18n:get-translations --verbose, you can see all the keys grouped by locale. I used that list to go to GlotPress and suggest the updated translations :)

@obulat obulat merged commit fe8b2bf into main Mar 24, 2024
39 checks passed
@obulat obulat deleted the add/locale-to-kebab-case-notice branch March 24, 2024 03:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🕹 aspect: interface Concerns end-users' experience with the software 🛠 goal: fix Bug fix 🟧 priority: high Stalls work on the project or its dependents 🧱 stack: frontend Related to the Nuxt frontend
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Kebab-cased translation key warning when running just p frontend i18n
5 participants