-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Sections in YML I18N File? #1641
Comments
Sections in yaml are not supported, only |
OK @AlbinoGeek , I've done that locally. Here is a full example of what the upcoming commit brings: Vars:
- minutes:
# possible values:
# other
# zero
# one
# two
# few
# many
# "=x" - where x is a number
# "<x"
# format - to customize the format, which defaults to %d .
one: "minute"
other: "minutes"
format: "%d" # defaults to that.
- dogs:
one: "dog"
other: "dogs"
- houses:
one: "house"
other: "houses"
- gender:
"=1": "She" # 1 for female
"=2": "He" # 2 for male
YouLate: "You are %[1]d ${minutes} late."
Classic: "classic"
FreeDay:
"=3": "You have three days and %[2]d ${minutes} off." # "FreeDay" 3, 15 (plurals + variable pluralization)
one: "You have a day off" # "FreeDay", 1
other: "You have %[1]d free days" # "FreeDay", 5
HeIsHome: "%s is home"
HouseCount: "${gender} (%[2]s) has %[3]d ${houses}"
# Local variables:
# HouseCount:
# Text: "${gender} has %[2]d ${houses}"
# Vars:
# - gender:
# "=1": "She" # 1 for female
# "=2": "He" # 2 for male
# - houses:
# one: "house"
# other: "houses"
root:
user: Account
nav:
home: Home # nav.home
user: '{{tr "root.user"}}' # nav.user
more:
what: "this" # nav.more.what
even:
more: "yes" # nav.more.even.more
aplural: "You are %[1]d ${minutes} late." # Tr("nav.more.even.aplural", 15) const (
female = iota + 1
male
)
app.Get("/", func(ctx iris.Context) {
classic := ctx.Tr("Classic")
oneMin := ctx.Tr("YouLate", 1)
twoMins := ctx.Tr("YouLate", 2)
oneDay := ctx.Tr("FreeDay", 1)
fiveDays := ctx.Tr("FreeDay", 5)
threeDaysPlusMinutes := ctx.Tr("FreeDay", 3, 15)
heIsHome := ctx.Tr("HeIsHome", "Peter")
houseCountFemale := ctx.Tr("HouseCount", female, "Maria", 2)
houseCountMale := ctx.Tr("HouseCount", male, "Peter", 1)
yamlSection := ctx.Tr("nav.user") + "\n" + ctx.Tr("nav.more.what") + "\n" + ctx.Tr("nav.more.even.more")
yamlSectionPlusPlural := ctx.Tr("nav.more.even.aplural", 15)
ctx.Writef("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s",
classic, oneMin, twoMins, oneDay, fiveDays, threeDaysPlusMinutes, heIsHome, houseCountFemale, houseCountMale,
yamlSection, yamlSectionPlusPlural)
}) classic
You are 1 minutes late.
You are 2 minutes late.
You have a day off
You have 5 free days
You have three days and 15 minutes off.
Peter is home
She (Maria) has 2 houses
He (Peter) has 1 houses
Account
this
yes
You are 15 minutes late. |
Ahh, so categorization of I18N only works in |
Yes but don't change your code yet, the commit will be pushed today. |
Summary
So, I translated my existing
.ini
internationalization file into.yml
format, but none of the keys registers now.I have confirmed the
.yml
file in question is being loaded as an intentional syntax error throws expected errors in iris startup.Code
Error
File
The text was updated successfully, but these errors were encountered: