-
Notifications
You must be signed in to change notification settings - Fork 2
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
Dzięki super paczka #10
Comments
Jak ktoś w przyszłości będzie potrzebował to załączam fragment kodu
Jeszcze raz dzięki za kluczowy warunek logiczny :) |
Niestety warunek Modulo 100 musi być różne niż 12, 13 i 14. A więc: if ([0, 1].includes(choice)) return choice;
const mod10: number = choice % 10;
const mod100: number = choice % 100;
if ([2, 3, 4].includes(mod10) && ![12, 13, 14].includes(mod100)) return 2;
return 3; ^ wersja pod Vue z 4 opcjami: To i tak tylko dla liczb całkowitych, na wymierne powinien być sprawdzany jeszcze dodatkowy warunek. |
@skix123 czy możesz podać przykład, w którym kod z tej paczki zawodzi? |
@skix123 przeprowadziłem następujący test: function polishPlurals1(singularNominativ, pluralNominativ, pluralGenitive, value) {
value = Math.abs(value);
if (value === 1) {
return singularNominativ;
} else if (value % 10 >= 2 && value % 10 <= 4 && (value % 100 < 10 || value % 100 >= 20)) {
return pluralNominativ;
} else {
return pluralGenitive;
}
}
function polishPlurals2(singularNominativ, pluralNominativ, pluralGenitive, value) {
value = Math.abs(value);
const mod10 = value % 10;
const mod100 = value % 100;
if (value === 1) {
return singularNominativ;
} else if ([2,3,4].includes(mod10) && ![12,13,14].includes(mod100)) {
return pluralNominativ;
} else {
return pluralGenitive;
}
}
for (let i = 0; i < 1000000; ++i) {
console.assert(
polishPlurals1("komentarz", "komentarze", "komentarzy", i)
===
polishPlurals2("komentarz", "komentarze", "komentarzy", i)
)
}
// brak błędów |
Ciekawe, zatem sory za wprowadzenie w błąd |
Właśnie sprawdzam jak to można wykorzystać w integracji z Vue
https://phrase.com/blog/posts/ultimate-guide-to-vue-localization-with-vue-i18n/#Custom_Pluralization
The text was updated successfully, but these errors were encountered: