Localization Language Contribution Guide
How to Add New Localized Language Support
Step 1: Copy Language Template File
# Copy lang/en.json as template
cp lang/en.json lang/xx.jsonWhere xx is the ISO639-1 language code for the language you want to add (such as zh-CN, ja, ko, etc.). For full language codes and language names, please refer to the appendix Language Codes.
Step 2: Update Template File Content
Edit the newly created lang/xx.json file such as lang/en.json, and translate all English content into the target language. Below is a complete example of an English language file:
{
"name": "English",
"author": "https://github.com/gouguoyin",
"months": "January|February|March|April|May|June|July|August|September|October|November|December",
"short_months": "Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec",
"weeks": "Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday",
"short_weeks": "Sun|Mon|Tue|Wed|Thu|Fri|Sat",
"seasons": "Spring|Summer|Autumn|Winter",
"constellations": "Aries|Taurus|Gemini|Cancer|Leo|Virgo|Libra|Scorpio|Sagittarius|Capricorn|Aquarius|Pisces",
"year": "1 year|%d years",
"month": "1 month|%d months",
"week": "1 week|%d weeks",
"day": "1 day|%d days",
"hour": "1 hour|%d hours",
"minute": "1 minute|%d minutes",
"second": "1 second|%d seconds",
"now": "just now",
"ago": "%s ago",
"from_now": "%s from now",
"before": "%s before",
"after": "%s after"
}Field Description
| Field | Description | Example |
|---|---|---|
name | ISO name | "English" |
author | Contributor's link | "https://github.com/your-username" |
months | Full month names, separated by | | "January|February|March..." |
short_months | Short month names, separated by | | "Jan|Feb|Mar..." |
weeks | Full week names, separated by | | "Sunday|Monday|Tuesday..." |
short_weeks | Short week names, separated by | | "Sun|Mon|Tue..." |
seasons | Season names, separated by | | "Spring|Summer|Autumn|Winter" |
constellations | Constellation names, separated by | | "Aries|Taurus|Gemini..." |
year | Year format, supports singular/plural | "1 year|%d years" |
month | Month format, supports singular/plural | "1 month|%d months" |
week | Week format, supports singular/plural | "1 week|%d weeks" |
day | Day format, supports singular/plural | "1 day|%d days" |
hour | Hour format, supports singular/plural | "1 hour|%d hours" |
minute | Minute format, supports singular/plural | "1 minute|%d minutes" |
second | Second format, supports singular/plural | "1 second|%d seconds" |
now | Translation of "now" | "just now" |
ago | Translation of "ago" | "%s ago" |
from_now | Translation of "from now" | "%s from now" |
before | Translation of "before" | "%s before" |
after | Translation of "after" | "%s after" |
Singular/Plural Description
East Asian Languages (Chinese, Japanese, Korean, etc.): Usually only use one format
json"year": "%d 年", "month": "%d 个月"Indo-European Languages (English, French, German, etc.): Need to distinguish singular/plural
json"year": "1 year|%d years", "month": "1 month|%d months"Slavic Languages (Russian, Ukrainian, etc.): May have more complex plural rules
json"year": "1 год|2 года|3 года|4 года|%d лет"
Step 3: Submit Pull Request
Create Branch
bashgit checkout -b add-xx-language-supportCommit Changes
bashgit add lang/xx.json git commit -m "add XX language support #39"Push and Create Pull Request
bashgit push origin add-xx-language-supportPull Request Title Format
Add XX Language Support #39
Step 4: Test Verification
Please ensure before submission:
- Correct JSON Format: Use
JSONvalidation tools to check syntax - Complete Fields: Ensure all required
20fields are included - Correct Separator: Use
|as array separator - Correct Placeholders: Use
%das number placeholder,%sas string placeholder - Maintain Consistency: Ensure translation style is consistent with existing language files
- Cultural Adaptability: Consider the cultural background and expression habits of the target language
Thank you for contributing new localized language support to the Carbon project!