plurals
This commit is contained in:
parent
ceb61e7e14
commit
c8a310c29b
3 changed files with 20 additions and 18 deletions
|
@ -124,16 +124,10 @@
|
||||||
"term.contributors": "Contributors",
|
"term.contributors": "Contributors",
|
||||||
"term.equalizer": "Equalizer",
|
"term.equalizer": "Equalizer",
|
||||||
"term.reset": "Reset",
|
"term.reset": "Reset",
|
||||||
"term.track": [
|
"term.track": {
|
||||||
{
|
"one" : "track",
|
||||||
"value": 1,
|
"other" : "tracks"
|
||||||
"text": "track"
|
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"value": 2,
|
|
||||||
"text": "tracks"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"term.tracks": "tracks", // Assume x amount of tracks. e.g. 50 tracks
|
"term.tracks": "tracks", // Assume x amount of tracks. e.g. 50 tracks
|
||||||
"term.videos": "Videos",
|
"term.videos": "Videos",
|
||||||
"term.menu": "Menu",
|
"term.menu": "Menu",
|
||||||
|
|
|
@ -324,13 +324,17 @@ const app = new Vue({
|
||||||
},
|
},
|
||||||
getLz(message, options = {}) {
|
getLz(message, options = {}) {
|
||||||
if (this.lz[message]) {
|
if (this.lz[message]) {
|
||||||
if(options["plural"]) {
|
if(options["count"] ) {
|
||||||
let closest = this.lz[message].reduce(function(prev, curr) {
|
if (typeof this.lz[message] === "object"){
|
||||||
return (Math.abs(curr.value - options["plural"]) < Math.abs(prev.value - options["plural"]) ? curr : prev);
|
let type = window.fastPluralRules.getPluralFormNameForCardinalByLocale(this.cfg.general.language.replace("_","-"),options["count"]);
|
||||||
});
|
return this.lz[message][type] ?? ((this.lz[message])[Object.keys(this.lz[message])[0]] ?? this.lz[message])
|
||||||
return closest.text;
|
} else {
|
||||||
|
// fallback English plural forms ( old i18n )
|
||||||
|
if (options["count"] > 1) {
|
||||||
|
return this.lz[message+ "s"] ?? this.lz[message]} else { return this.lz[message]}
|
||||||
|
}
|
||||||
} else if(typeof this.lz[message] === "object") {
|
} else if(typeof this.lz[message] === "object") {
|
||||||
return this.lz[message][0].text;
|
return (this.lz[message])[Object.keys(this.lz[message])[0]]
|
||||||
}
|
}
|
||||||
return this.lz[message]
|
return this.lz[message]
|
||||||
} else {
|
} else {
|
||||||
|
@ -2149,7 +2153,10 @@ const app = new Vue({
|
||||||
let hours = Math.floor(time / 3600)
|
let hours = Math.floor(time / 3600)
|
||||||
let mins = Math.floor(time / 60) % 60
|
let mins = Math.floor(time / 60) % 60
|
||||||
let secs = time % 60
|
let secs = time % 60
|
||||||
return app.showingPlaylist.relationships.tracks.data.length + " " + app.getLz('term.tracks') + ", " + ((hours > 0) ? (hours + (" " + ((hours > 1) ? app.getLz('term.time.hours') + ", " : app.getLz('term.time.hour') + ", "))) : "") + ((mins > 0) ? (mins + ((mins > 1) ? " " + app.getLz('term.time.minutes') + ", " : " " + app.getLz('term.time.minute') + ", ")) : "") + secs + ((secs > 1) ? " " + app.getLz('term.time.seconds') + "." : " " + app.getLz('term.time.second') + ".");
|
return app.showingPlaylist.relationships.tracks.data.length + " " + app.getLz('term.track', options = {count : app.showingPlaylist.relationships.tracks.data.length}) + ", "
|
||||||
|
+ ((hours > 0) ? (hours + (" " + (app.getLz('term.time.hour', options = {count : hours}) + ", "))) : "") +
|
||||||
|
((mins > 0) ? (mins + (" " + app.getLz('term.time.minute', options = {count : mins}) + ", ")) : "") +
|
||||||
|
secs + (" " + app.getLz('term.time.second', options = {count : secs}) + ".");
|
||||||
} else return ""
|
} else return ""
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return ""
|
return ""
|
||||||
|
|
|
@ -72,6 +72,7 @@
|
||||||
document.write(unescape("%3Cscript src='https://js-cdn.music.apple.com/musickit/v2/amp/musickit.js' type='text/javascript'%3E%3C/script%3E"));
|
document.write(unescape("%3Cscript src='https://js-cdn.music.apple.com/musickit/v2/amp/musickit.js' type='text/javascript'%3E%3C/script%3E"));
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
<script src="https://unpkg.com/fast-plural-rules@1.0.2/dist/index.umd.min.js"></script>
|
||||||
<script
|
<script
|
||||||
src="index.js?v=1"></script>
|
src="index.js?v=1"></script>
|
||||||
<script
|
<script
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue