mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2023-06-08.git
synced 2024-08-15 00:53:38 +00:00
Add support for plurlization to locales
This commit is contained in:
parent
03891b66b6
commit
6cdb6ec711
3 changed files with 79 additions and 18 deletions
|
@ -1,6 +1,12 @@
|
||||||
{
|
{
|
||||||
"`x` subscribers": "`x` subscribers",
|
"`x` subscribers": {
|
||||||
"`x` videos": "`x` videos",
|
"(\\D|^)1(\\D|$)": "`x` subscriber",
|
||||||
|
"": "`x` subscribers"
|
||||||
|
},
|
||||||
|
"`x` videos": {
|
||||||
|
"(\\D|^)1(\\D|$)": "`x` video",
|
||||||
|
"": "`x` videos"
|
||||||
|
},
|
||||||
"LIVE": "LIVE",
|
"LIVE": "LIVE",
|
||||||
"Shared `x` ago": "Shared `x` ago",
|
"Shared `x` ago": "Shared `x` ago",
|
||||||
"Unsubscribe": "Unsubscribe",
|
"Unsubscribe": "Unsubscribe",
|
||||||
|
@ -102,13 +108,22 @@
|
||||||
"Subscription manager": "Subscription manager",
|
"Subscription manager": "Subscription manager",
|
||||||
"Token manager": "Token manager",
|
"Token manager": "Token manager",
|
||||||
"Token": "Token",
|
"Token": "Token",
|
||||||
"`x` subscriptions": "`x` subscriptions",
|
"`x` subscriptions": {
|
||||||
"`x` tokens": "`x` tokens",
|
"(\\D|^)1(\\D|$)": "`x` subscription",
|
||||||
|
"": "`x` subscriptions"
|
||||||
|
},
|
||||||
|
"`x` tokens": {
|
||||||
|
"(\\D|^)1(\\D|$)": "`x` token",
|
||||||
|
"": "`x` tokens"
|
||||||
|
},
|
||||||
"Import/export": "Import/export",
|
"Import/export": "Import/export",
|
||||||
"unsubscribe": "unsubscribe",
|
"unsubscribe": "unsubscribe",
|
||||||
"revoke": "revoke",
|
"revoke": "revoke",
|
||||||
"Subscriptions": "Subscriptions",
|
"Subscriptions": "Subscriptions",
|
||||||
"`x` unseen notifications": "`x` unseen notifications",
|
"`x` unseen notifications": {
|
||||||
|
"(\\D|^)1(\\D|$)": "`x` unseen notification",
|
||||||
|
"": "`x` unseen notifications"
|
||||||
|
},
|
||||||
"search": "search",
|
"search": "search",
|
||||||
"Log out": "Log out",
|
"Log out": "Log out",
|
||||||
"Released under the AGPLv3 by Omar Roth.": "Released under the AGPLv3 by Omar Roth.",
|
"Released under the AGPLv3 by Omar Roth.": "Released under the AGPLv3 by Omar Roth.",
|
||||||
|
@ -126,7 +141,10 @@
|
||||||
"Whitelisted regions: ": "Whitelisted regions: ",
|
"Whitelisted regions: ": "Whitelisted regions: ",
|
||||||
"Blacklisted regions: ": "Blacklisted regions: ",
|
"Blacklisted regions: ": "Blacklisted regions: ",
|
||||||
"Shared `x`": "Shared `x`",
|
"Shared `x`": "Shared `x`",
|
||||||
"`x` views": "`x` views",
|
"`x` views": {
|
||||||
|
"(\\D|^)1(\\D|$)": "`x` views",
|
||||||
|
"": "`x` views"
|
||||||
|
},
|
||||||
"Premieres in `x`": "Premieres in `x`",
|
"Premieres in `x`": "Premieres in `x`",
|
||||||
"Hi! Looks like you have JavaScript turned off. Click here to view comments, keep in mind they may take a bit longer to load.": "Hi! Looks like you have JavaScript turned off. Click here to view comments, keep in mind they may take a bit longer to load.",
|
"Hi! Looks like you have JavaScript turned off. Click here to view comments, keep in mind they may take a bit longer to load.": "Hi! Looks like you have JavaScript turned off. Click here to view comments, keep in mind they may take a bit longer to load.",
|
||||||
"View YouTube comments": "View YouTube comments",
|
"View YouTube comments": "View YouTube comments",
|
||||||
|
@ -156,10 +174,16 @@
|
||||||
"This channel does not exist.": "This channel does not exist.",
|
"This channel does not exist.": "This channel does not exist.",
|
||||||
"Could not get channel info.": "Could not get channel info.",
|
"Could not get channel info.": "Could not get channel info.",
|
||||||
"Could not fetch comments": "Could not fetch comments",
|
"Could not fetch comments": "Could not fetch comments",
|
||||||
"View `x` replies": "View `x` replies",
|
"View `x` replies": {
|
||||||
|
"(\\D|^)1(\\D|$)": "View `x` reply",
|
||||||
|
"": "View `x` replies"
|
||||||
|
},
|
||||||
"`x` ago": "`x` ago",
|
"`x` ago": "`x` ago",
|
||||||
"Load more": "Load more",
|
"Load more": "Load more",
|
||||||
"`x` points": "`x` points",
|
"`x` points": {
|
||||||
|
"(\\D|^)1(\\D|$)": "`x` point",
|
||||||
|
"": "`x` points"
|
||||||
|
},
|
||||||
"Could not create mix.": "Could not create mix.",
|
"Could not create mix.": "Could not create mix.",
|
||||||
"Empty playlist": "Empty playlist",
|
"Empty playlist": "Empty playlist",
|
||||||
"Not a playlist.": "Not a playlist.",
|
"Not a playlist.": "Not a playlist.",
|
||||||
|
@ -277,13 +301,34 @@
|
||||||
"Yiddish": "Yiddish",
|
"Yiddish": "Yiddish",
|
||||||
"Yoruba": "Yoruba",
|
"Yoruba": "Yoruba",
|
||||||
"Zulu": "Zulu",
|
"Zulu": "Zulu",
|
||||||
"`x` years": "`x` years",
|
"`x` years": {
|
||||||
"`x` months": "`x` months",
|
"(\\D|^)1(\\D|$)": "`x` year",
|
||||||
"`x` weeks": "`x` weeks",
|
"": "`x` years"
|
||||||
"`x` days": "`x` days",
|
},
|
||||||
"`x` hours": "`x` hours",
|
"`x` months": {
|
||||||
"`x` minutes": "`x` minutes",
|
"(\\D|^)1(\\D|$)": "`x` month",
|
||||||
"`x` seconds": "`x` seconds",
|
"": "`x` months"
|
||||||
|
},
|
||||||
|
"`x` weeks": {
|
||||||
|
"(\\D|^)1(\\D|$)": "`x` week",
|
||||||
|
"": "`x` weeks"
|
||||||
|
},
|
||||||
|
"`x` days": {
|
||||||
|
"(\\D|^)1(\\D|$)": "`x` day",
|
||||||
|
"": "`x` days"
|
||||||
|
},
|
||||||
|
"`x` hours": {
|
||||||
|
"(\\D|^)1(\\D|$)": "`x` hour",
|
||||||
|
"": "`x` hours"
|
||||||
|
},
|
||||||
|
"`x` minutes": {
|
||||||
|
"(\\D|^)1(\\D|$)": "`x` minute",
|
||||||
|
"": "`x` minutes"
|
||||||
|
},
|
||||||
|
"`x` seconds": {
|
||||||
|
"(\\D|^)1(\\D|$)": "`x` second",
|
||||||
|
"": "`x` seconds"
|
||||||
|
},
|
||||||
"Fallback comments: ": "Fallback comments: ",
|
"Fallback comments: ": "Fallback comments: ",
|
||||||
"Popular": "Popular",
|
"Popular": "Popular",
|
||||||
"Top": "Top",
|
"Top": "Top",
|
||||||
|
|
|
@ -7,8 +7,24 @@ def translate(locale : Hash(String, JSON::Any) | Nil, translation : String, text
|
||||||
# puts "Could not find translation for #{translation.dump}"
|
# puts "Could not find translation for #{translation.dump}"
|
||||||
# end
|
# end
|
||||||
|
|
||||||
if locale && locale[translation]? && !locale[translation].as_s.empty?
|
if locale && locale[translation]?
|
||||||
translation = locale[translation].as_s
|
case locale[translation]
|
||||||
|
when .as_h?
|
||||||
|
match_length = 0
|
||||||
|
|
||||||
|
locale[translation].as_h.each do |key, value|
|
||||||
|
if md = text.try &.match(/#{key}/)
|
||||||
|
if md[0].size >= match_length
|
||||||
|
translation = value.as_s
|
||||||
|
match_length = md[0].size
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
when .as_s?
|
||||||
|
if !locale[translation].as_s.empty?
|
||||||
|
translation = locale[translation].as_s
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if text
|
if text
|
||||||
|
|
Loading…
Reference in a new issue