Fix issue #642, frontend not in english if the user language does not exist #648
Brak recenzentów
Etykiety
Brak etykiet
A: API
A: Backend
A: Federation
A: Front-End
A: I18N
A: Meta
A: Security
Build
C: Bug
C: Discussion
C: Enhancement
C: Feature
Compatibility
Dependency
Design
Documentation
Good first issue
Help welcome
Mobile
Rendering
S: Blocked
S: Duplicate
S: Incomplete
S: Instance specific
S: Invalid
S: Needs Voting/Discussion
S: Ready for review
Suggestion
S: Voted on Loomio
S: Wontfix
Brak kamienia milowego
Brak projektu
Brak przypisanych
Uczestnicy 2
Powiadomienia
Termin realizacji
Brak ustawionego terminu realizacji.
Zależności
Brak ustawionych zależności.
Odniesienie: Plume/Plume#648
Ładowanie…
Dodaj tabelę
Odniesienie w nowym zgłoszeniu
Opis zgłoszenia jest pusty.
Usuń gałąź "issue-frontend-language"
Usunięcie gałęzi jest permanentne. Mimo, że usunięta gałąź może istnieć przez krótki czas zanim zostanie rzeczywiście usunięta, ta operacja NIE MOŻE zostać cofnięta w większości przypadków. Kontynuować?
Fix #642
Iterate over catalogs to find the english index and then use it instead of 0.
Codecov Report
Codecov Report
please ignore my rambling
@ -47,2 +47,4 @@
let lang = js! { return navigator.language }.into_string().unwrap();
let lang = lang.splitn(2, '-').next().unwrap_or("en");
let english_position = catalogs
this should be either a (cached?) constant, or a (cached?) config value
@ -49,0 +50,4 @@
let english_position = catalogs
.iter()
.position(|(language_code, _)| *language_code == "en")
.unwrap();
while i understand that this is a simple operation, i don't think we need to do it every time
actually, never mind, this is an operation that's only dealing with things known at compile time
the optimiser will probably inline this as a constant literal
@ -47,2 +47,4 @@
let lang = js! { return navigator.language }.into_string().unwrap();
let lang = lang.splitn(2, '-').next().unwrap_or("en");
let english_position = catalogs
It should be a constant yes, but the rust doc of constant says :
So i thought the keyword const was forbidden in this case.
@ -47,2 +47,4 @@
let lang = js! { return navigator.language }.into_string().unwrap();
let lang = lang.splitn(2, '-').next().unwrap_or("en");
let english_position = catalogs
All this is in a lazy_static! call, so the result will be evaluated only one time, the first time CATALOG is accessed. The only thing it's not is cached between two different page loading, but that's not necessary imo