feat: Add Azerbaijani language to i18n package#164
Conversation
WalkthroughA new Go file has been introduced to provide Azerbaijani translations for validation error messages. It defines a variable containing a nested map structure, mapping validation types and issue codes to Azerbaijani message templates with dynamic placeholders, supporting both positive and negative validation scenarios. Changes
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
🧪 Generate Unit Tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
i18n/az/az.go(1 hunks)
🔇 Additional comments (7)
i18n/az/az.go (7)
1-2: Package declaration is correct
Theazpackage name aligns with the Azerbaijani locale code.
3-5: Imports look good
Thezconstimport path is correct and used consistently in the map.
7-7: Ensure language registration
Make sure you’ve addedaz.Mapto the global language registry in the main i18n package so that these translations are picked up at runtime.
8-40: String translations are comprehensive
All common string validation issue codes and their negations are covered with appropriate placeholders.
41-48: Boolean translations are correct
The boolean issue codes (Required,NotNil,True,False,EQ) are translated as expected.
62-69: Time translations are accurate
The time-related codes (After,Before,EQ) and their messages are properly localized.
81-90: Struct translations are in place
The struct validation messages, including JSON and ZHTTP issues, are fully covered.
| zconst.TypeNumber: { | ||
| zconst.IssueCodeRequired: "tələb olunur", | ||
| zconst.IssueCodeNotNil: "boş olmamalıdır", | ||
| zconst.IssueCodeLTE: "rəqəm {{lte}}-dən kiçik və ya bərabər olmalıdır", | ||
| zconst.IssueCodeLT: "rəqəm {{lt}}-dən kiçik olmalıdır", | ||
| zconst.IssueCodeGTE: "rəqəm {{gte}}-dən böyük və ya bərabər olmalıdır", | ||
| zconst.IssueCodeGT: "rəqəm {{gt}}-dən böyük olmalıdır", | ||
| zconst.IssueCodeEQ: "rəqəm {{eq}}-ə bərabər olmalıdır", | ||
| zconst.NotIssueCode(zconst.IssueCodeEQ): "rəqəm {{eq}}-ə bərabər olmamalıdır", | ||
| zconst.IssueCodeOneOf: "rəqəm {{options}} variantlarından biri olmalıdır", | ||
| zconst.NotIssueCode(zconst.IssueCodeOneOf): "rəqəm {{options}} variantlarından biri olmamalıdır", | ||
| zconst.IssueCodeFallback: "rəqəm yanlışdır", | ||
| }, |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Unify placeholder names for one-of options
In the number block, you use the {{options}} placeholder, but in the string block it’s {{one_of_options}}. Use a consistent placeholder key across types to avoid mismatches during substitution.
Proposed diff:
- zconst.IssueCodeOneOf: "rəqəm {{options}} variantlarından biri olmalıdır",
- zconst.NotIssueCode(zconst.IssueCodeOneOf): "rəqəm {{options}} variantlarından biri olmamalıdır",
+ zconst.IssueCodeOneOf: "rəqəm {{one_of_options}} variantlarından biri olmalıdır",
+ zconst.NotIssueCode(zconst.IssueCodeOneOf): "rəqəm {{one_of_options}} variantlarından biri olmamalıdır",📝 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.
| zconst.TypeNumber: { | |
| zconst.IssueCodeRequired: "tələb olunur", | |
| zconst.IssueCodeNotNil: "boş olmamalıdır", | |
| zconst.IssueCodeLTE: "rəqəm {{lte}}-dən kiçik və ya bərabər olmalıdır", | |
| zconst.IssueCodeLT: "rəqəm {{lt}}-dən kiçik olmalıdır", | |
| zconst.IssueCodeGTE: "rəqəm {{gte}}-dən böyük və ya bərabər olmalıdır", | |
| zconst.IssueCodeGT: "rəqəm {{gt}}-dən böyük olmalıdır", | |
| zconst.IssueCodeEQ: "rəqəm {{eq}}-ə bərabər olmalıdır", | |
| zconst.NotIssueCode(zconst.IssueCodeEQ): "rəqəm {{eq}}-ə bərabər olmamalıdır", | |
| zconst.IssueCodeOneOf: "rəqəm {{options}} variantlarından biri olmalıdır", | |
| zconst.NotIssueCode(zconst.IssueCodeOneOf): "rəqəm {{options}} variantlarından biri olmamalıdır", | |
| zconst.IssueCodeFallback: "rəqəm yanlışdır", | |
| }, | |
| zconst.TypeNumber: { | |
| zconst.IssueCodeRequired: "tələb olunur", | |
| zconst.IssueCodeNotNil: "boş olmamalıdır", | |
| zconst.IssueCodeLTE: "rəqəm {{lte}}-dən kiçik və ya bərabər olmalıdır", | |
| zconst.IssueCodeLT: "rəqəm {{lt}}-dən kiçik olmalıdır", | |
| zconst.IssueCodeGTE: "rəqəm {{gte}}-dən böyük və ya bərabər olmalıdır", | |
| zconst.IssueCodeGT: "rəqəm {{gt}}-dən böyük olmalıdır", | |
| zconst.IssueCodeEQ: "rəqəm {{eq}}-ə bərabər olmalıdır", | |
| zconst.NotIssueCode(zconst.IssueCodeEQ): "rəqəm {{eq}}-ə bərabər olmamalıdır", | |
| zconst.IssueCodeOneOf: "rəqəm {{one_of_options}} variantlarından biri olmalıdır", | |
| zconst.NotIssueCode(zconst.IssueCodeOneOf): "rəqəm {{one_of_options}} variantlarından biri olmamalıdır", | |
| zconst.IssueCodeFallback: "rəqəm yanlışdır", | |
| }, |
🤖 Prompt for AI Agents
In i18n/az/az.go between lines 49 and 61, the placeholder for the one-of options
is inconsistent; it uses {{options}} here but {{one_of_options}} elsewhere. To
fix this, unify the placeholder name by replacing all instances of {{options}}
with {{one_of_options}} in this number block to ensure consistent substitution
across types.
|
Hey! I really appreciate you taking the time to translate the errors and make the PR. And thank you for your kind words! I'm a bit hesitant to add first party error maps for other languages as I will not be able to keep the maps up to date. I can do so for english and spanish as I speak both of those languages. But it would be awesome for the community to be able to have access to this ready made translations. I'm undecided on the best approach to take though, some of the ideas that have come to mind are:
What do you think? Any ideas? |
|
I understand your hesitation. Using GPT to generate translations and then accepting PRs to correct any mistakes seems like the most practical approach for now. (I’d be happy to help maintain the Azerbaijani translations and address any issues that come up.) Since users can temporarily override incorrect translations until patches are available, this seems like a reasonable solution at this stage. |
|
Hey! Sorry to have taken so long to reply. I have been very busy with work and was also pondering this. I think I agree with you. And I very much appreciate your kindness in offering to maintain it. For now lets merge this as a third party maintained language (or something like that). I'll add it to the docs. In the future I would like to build something to auto handles the translations, we have something like that at work. |
* feat: add az package to i18n * fix typos
* feat: add az package to i18n * fix typos
This pull request adds Azerbaijani (az) language support for validation messages.
Let me know if any adjustments are needed.
Thanks for your great work on this library!
Summary by CodeRabbit