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

Adding i18n initial support #155

Merged
merged 1 commit into from
Aug 4, 2024
Merged

Adding i18n initial support #155

merged 1 commit into from
Aug 4, 2024

Conversation

tankerkiller125
Copy link
Contributor

@tankerkiller125 tankerkiller125 commented Aug 4, 2024

What type of PR is this?

  • feature

What this PR does / why we need it:

This is just the initial support for i18n, it's setup in the following way:

There are still things that need to be figured out:

  • Switching the locale (user preference? Or somehow pass it forward from the backend?)
  • All of the pages need converting to the i18n string output method (the initial index should be mostly done).

Which issue(s) this PR fixes:

Fixes: #32

Summary by CodeRabbit

  • New Features

    • Introduced internationalization support for the password strength label and various UI text elements.
    • Added a new localization file for English strings, enhancing the user interface with dynamic translations.
    • Implemented a plugin for managing multilingual content and improved message formatting.
  • Bug Fixes

    • Replaced static text with dynamic translations throughout the main page for better accessibility.
  • Chores

    • Updated configuration to integrate i18n support and added necessary dependencies for localization.

Copy link
Contributor

coderabbitai bot commented Aug 4, 2024

Walkthrough

Walkthrough

The recent changes enhance the application's internationalization capabilities by implementing support for multiple languages. Key modifications include the localization of text labels in the user interface, the introduction of an English localization file, and updates to the Nuxt configuration for i18n support. These improvements facilitate a more inclusive user experience, making it easier for users to engage with the application in their preferred language.

Changes

File Summary of Changes
frontend/components/global/PasswordScore.vue
frontend/pages/index.vue
Localization of text strings using the $t() function for dynamic translation, enhancing multilingual support.
frontend/locales/en.json5 New file added with English localization strings for various UI elements, improving user experience through language support.
frontend/nuxt.config.ts Integrated i18n support with configurations for vue-i18n and Vite, enabling better handling of localization.
frontend/package.json Added dependencies for @intlify/unplugin-vue-i18n, intl-messageformat, and vue-i18n to enhance localization features.
frontend/plugins/i18n.ts New plugin created to initialize i18n with custom message formatting and error handling, improving multilingual content management.

Assessment against linked issues

Objective Addressed Explanation
Support Simplified Chinese (#32) While English localization has been implemented, it is unclear if Simplified Chinese support is included.

🎉 In code we weave, a language so bright,
With words that now dance, in day and in night.
From English to Chinese, let voices unite,
A global embrace, our future in sight! 🌍✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Inline review comments failed to post

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0bcb155 and 3540ce4.

Files ignored due to path filters (1)
  • frontend/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
Files selected for processing (6)
  • frontend/components/global/PasswordScore.vue (1 hunks)
  • frontend/locales/en.json5 (1 hunks)
  • frontend/nuxt.config.ts (1 hunks)
  • frontend/package.json (2 hunks)
  • frontend/pages/index.vue (5 hunks)
  • frontend/plugins/i18n.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • frontend/locales/en.json5
Additional context used
Biome
frontend/plugins/i18n.ts

[error] 33-33: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

Additional comments not posted (18)
frontend/components/global/PasswordScore.vue (1)

3-3: Localization implemented successfully.

The label "Password Strength" has been successfully localized using the $t function. This change enhances the user interface by supporting multiple languages.

frontend/plugins/i18n.ts (1)

1-16: i18n plugin setup looks good.

The setup for the Vue I18n library and the integration with the Vue app is correctly implemented.

frontend/nuxt.config.ts (3)

1-1: Imports for i18n support are correctly added.

The necessary imports for the Vue I18n plugin and path resolution are correctly added.


9-11: Transpilation settings for vue-i18n are correctly configured.

The build configuration includes the vue-i18n library for transpilation, ensuring compatibility during the build process.


12-17: Vite plugin for i18n support is correctly configured.

The Vite configuration includes the Vue I18n plugin, with the correct path to the locale files.

frontend/package.json (3)

19-19: Addition of @intlify/unplugin-vue-i18n is appropriate.

This dependency is essential for integrating Vue I18n support into the project, facilitating internationalization.


31-31: Addition of intl-messageformat is appropriate.

This dependency is vital for handling internationalized message formatting, ensuring dynamic text rendering based on the user's locale.


39-39: Addition of vue-i18n is appropriate.

This dependency is fundamental for enabling internationalization in Vue applications, providing essential tools and functions.

frontend/pages/index.vue (10)

152-152: Dynamic translation of the tagline is appropriate.

This change ensures the tagline is rendered based on the user's language preference, enhancing accessibility.


177-177: Dynamic translation of the registration heading is appropriate.

This change ensures the registration heading is rendered based on the user's language preference, enhancing accessibility.


179-179: Dynamic translation of the email input label is appropriate.

This change ensures the label is rendered based on the user's language preference, enhancing accessibility.


182-182: Dynamic translation of the group joining text is appropriate.

This change ensures the text is rendered based on the user's language preference, enhancing accessibility.


184-184: Dynamic translation of the button text for not joining a group is appropriate.

This change ensures the button text is rendered based on the user's language preference, enhancing accessibility.


187-187: Dynamic translation of the password input label is appropriate.

This change ensures the label is rendered based on the user's language preference, enhancing accessibility.


196-196: Dynamic translation of the registration button text is appropriate.

This change ensures the button text is rendered based on the user's language preference, enhancing accessibility.


207-207: Dynamic translation of the login heading is appropriate.

This change ensures the login heading is rendered based on the user's language preference, enhancing accessibility.


211-211: Dynamic translation of the email label in the demo instance is appropriate.

This change ensures the email label is rendered based on the user's language preference, enhancing accessibility.


212-212: Dynamic translation of the password label in the demo instance is appropriate.

This change ensures the password label is rendered based on the user's language preference, enhancing accessibility.

Comments failed to post (1)
frontend/plugins/i18n.ts

18-36: Consider using optional chaining for error handling.

The static analysis tool suggests using optional chaining for better readability and safety.

-    onError && onError(new Error("not support for AST") as CompileError);
+    onError?.(new Error("not support for AST") as CompileError);
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

export const messageCompiler: MessageCompiler = (message, { locale, key, onError }) => {
  if (typeof message === "string") {
    /**
     * You can tune your message compiler performance more with your cache strategy or also memoization at here
     */
    const formatter = new IntlMessageFormat(message, locale);
    return (ctx: MessageContext) => {
      return formatter.format(ctx.values);
    };
  } else {
    /**
     * for AST.
     * If you would like to support it,
     * You need to transform locale messages such as `json`, `yaml`, etc. with the bundle plugin.
     */
    onError?.(new Error("not support for AST") as CompileError);
    return () => key;
  }
};
Tools
Biome

[error] 33-33: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

@tankerkiller125 tankerkiller125 marked this pull request as ready for review August 4, 2024 15:02
@tankerkiller125 tankerkiller125 merged commit 236c257 into main Aug 4, 2024
5 checks passed
truecharts-admin referenced this pull request in truecharts/public Sep 5, 2024
… v0.14.0@9f47d0f by renovate (#25934)

This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
|
[ghcr.io/sysadminsmedia/homebox](https://redirect.github.com/sysadminsmedia/homebox)
| minor | `0.13.0` -> `0.14.0` |

---

> [!WARNING]
> Some dependencies could not be looked up. Check the Dependency
Dashboard for more information.

---

### Release Notes

<details>
<summary>sysadminsmedia/homebox
(ghcr.io/sysadminsmedia/homebox)</summary>

###
[`v0.14.0`](https://redirect.github.com/sysadminsmedia/homebox/releases/tag/v0.14.0)

[Compare
Source](https://redirect.github.com/sysadminsmedia/homebox/compare/v0.13.0...v0.14.0)

> \[!NOTE]\
> We are aware of some users having issues with the v0.12.0 -> v0.13.0
update on docker specifically, we have so far been unable to replicate
the issue and as such this version does not contain a patch for it. We
want to reassure you though that we are committed to getting to the
bottom of that issue and fixing it, whether that be a patch release, or
something that goes in a fuller release.

#### Homebox Goes International (Languages)

This update contains many fixes, and small resolutions, but it also
contains a HUGE update in terms of making Homebox more accessible to
international users. We've finally added i18n support to Homebox,
allowing users to use Homebox in their own language. It's still early
days, we've translated the majority of the main pages, and we continue
working on it.

To use translations, simply open Homebox, it's really that simple, it
will use whatever the default language setting your browser is set to
use. And fallback to English if your preferred language isn't yet
available. If your language isn't yet available, please consider
[contributing](https://translate.sysadminsmedia.com/projects/homebox/frontend/).
For those that have already contributed, both those named, and those
that don't have your GitHub linked in Weblate (and thus don't appear in
commit messages to mention) thank you so much, we couldn't possible
translate Homebox into so many languages ourselves.

[![Translation
status](http://translate.sysadminsmedia.com/widget/homebox/multi-auto.svg)](http://translate.sysadminsmedia.com/engage/homebox/)

Additionally, we purchased the https://homebox.software domain to give
Homebox a home of it's own on the internet. Which should not only make
it more findable for SEO reasons, but also make it easier to remember
the link to the documentation/home page. Additionally, we setup some
sub-domains to redirect to various sites such as
https://git.homebox.software for Github,
https://discord.homebox.software to go to our Discord server, etc.

#### What's Changed

- Fix small typo in label discussion thread URL by
[@&#8203;victorhooi](https://redirect.github.com/victorhooi) in
[https://github.com/sysadminsmedia/homebox/pull/149](https://redirect.github.com/sysadminsmedia/homebox/pull/149)
- Document search tips, cleanup documentation by
[@&#8203;blessedbiped](https://redirect.github.com/blessedbiped) in
[https://github.com/sysadminsmedia/homebox/pull/152](https://redirect.github.com/sysadminsmedia/homebox/pull/152)
- Fixes to the Tools page by
[@&#8203;rpavlik](https://redirect.github.com/rpavlik) in
[https://github.com/sysadminsmedia/homebox/pull/154](https://redirect.github.com/sysadminsmedia/homebox/pull/154)
- Adding i18n initial support by
[@&#8203;tankerkiller125](https://redirect.github.com/tankerkiller125)
in
[https://github.com/sysadminsmedia/homebox/pull/155](https://redirect.github.com/sysadminsmedia/homebox/pull/155)
- changed companyname and url to sysadminsmedia.com by
[@&#8203;101br03k](https://redirect.github.com/101br03k) in
[https://github.com/sysadminsmedia/homebox/pull/158](https://redirect.github.com/sysadminsmedia/homebox/pull/158)
- \[LANGUAGE UPDATE] Frontend translations for Italian and German by
[@&#8203;lukasitaly](https://redirect.github.com/lukasitaly) in
[https://github.com/sysadminsmedia/homebox/pull/170](https://redirect.github.com/sysadminsmedia/homebox/pull/170)
- Adding email validator by
[@&#8203;RomuloGatto](https://redirect.github.com/RomuloGatto) in
[https://github.com/sysadminsmedia/homebox/pull/178](https://redirect.github.com/sysadminsmedia/homebox/pull/178)
- fix: CSV export not including item notes by
[@&#8203;LarssonOliver](https://redirect.github.com/LarssonOliver) in
[https://github.com/sysadminsmedia/homebox/pull/180](https://redirect.github.com/sysadminsmedia/homebox/pull/180)
- added the ability to add a photo in the item creation modal by
[@&#8203;cjmielke](https://redirect.github.com/cjmielke) in
[https://github.com/sysadminsmedia/homebox/pull/173](https://redirect.github.com/sysadminsmedia/homebox/pull/173)

#### New Contributors

- [@&#8203;victorhooi](https://redirect.github.com/victorhooi) made
their first contribution in
[https://github.com/sysadminsmedia/homebox/pull/149](https://redirect.github.com/sysadminsmedia/homebox/pull/149)
- [@&#8203;blessedbiped](https://redirect.github.com/blessedbiped) made
their first contribution in
[https://github.com/sysadminsmedia/homebox/pull/152](https://redirect.github.com/sysadminsmedia/homebox/pull/152)
- [@&#8203;rpavlik](https://redirect.github.com/rpavlik) made their
first contribution in
[https://github.com/sysadminsmedia/homebox/pull/154](https://redirect.github.com/sysadminsmedia/homebox/pull/154)
- [@&#8203;lukasitaly](https://redirect.github.com/lukasitaly) made
their first contribution in
[https://github.com/sysadminsmedia/homebox/pull/170](https://redirect.github.com/sysadminsmedia/homebox/pull/170)
- [@&#8203;RomuloGatto](https://redirect.github.com/RomuloGatto) made
their first contribution in
[https://github.com/sysadminsmedia/homebox/pull/178](https://redirect.github.com/sysadminsmedia/homebox/pull/178)
- [@&#8203;LarssonOliver](https://redirect.github.com/LarssonOliver)
made their first contribution in
[https://github.com/sysadminsmedia/homebox/pull/180](https://redirect.github.com/sysadminsmedia/homebox/pull/180)
- [@&#8203;cjmielke](https://redirect.github.com/cjmielke) made their
first contribution in
[https://github.com/sysadminsmedia/homebox/pull/173](https://redirect.github.com/sysadminsmedia/homebox/pull/173)

#### Translation Contributors

Please note, this list is based on Github Commits from Weblate, it may
not be 100% accurate, or contain all contributors.

- [@&#8203;SKNTim](https://redirect.github.com/SKNTim) (Chinese
Traditional)
- [@&#8203;olsson82](https://redirect.github.com/olsson82) (Chinese
Traditional)
- [@&#8203;101br03k](https://redirect.github.com/101br03k) (Chinese
Traditional, Swedish, French)
- [@&#8203;Jackxwb](https://redirect.github.com/Jackxwb) (Chinese
Simplified)
-   [@&#8203;SodaSyrup](https://redirect.github.com/SodaSyrup) (Turkish)
- [@&#8203;N0namenull](https://redirect.github.com/N0namenull) (Russian)
-   [@&#8203;scyllaL](https://redirect.github.com/scyllaL) (Russian)
-   [@&#8203;Slydite4](https://redirect.github.com/Slydite4) (Spanish)
- [@&#8203;HydrelioxGitHub](https://redirect.github.com/HydrelioxGitHub)
(French)
-   [@&#8203;chevdor](https://redirect.github.com/chevdor) (French)
- [@&#8203;lukasitaly](https://redirect.github.com/lukasitaly) (Italian,
German, French)
- [@&#8203;olsson82](https://redirect.github.com/olsson82) (Swedish,
German)
-   [@&#8203;terenc3](https://redirect.github.com/terenc3) (German)

**Full Changelog**:
sysadminsmedia/homebox@v0.13.0...v0.14.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Renovate
Bot](https://redirect.github.com/renovatebot/renovate).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC42Ny40IiwidXBkYXRlZEluVmVyIjoiMzguNjcuNCIsInRhcmdldEJyYW5jaCI6Im1hc3RlciIsImxhYmVscyI6WyJhdXRvbWVyZ2UiLCJ1cGRhdGUvZG9ja2VyL2dlbmVyYWwvbm9uLW1ham9yIl19-->
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.

Hope to support Simplified Chinese
1 participant