Fix issue #642, frontend not in english if the user language does not exist #648

Samengevoegd
requiem958 heeft 2 commits samengevoegd van issue-frontend-language naar master 5 jaren geleden
requiem958 reageerde 5 jaren geleden (Gemigreerd van github.com)

Fix #642

Iterate over catalogs to find the english index and then use it instead of 0.

Fix [#642](https://github.com/Plume-org/Plume/issues/642) Iterate over catalogs to find the english index and then use it instead of 0.
codecov[bot] reageerde 5 jaren geleden (Gemigreerd van github.com)

Codecov Report

Merging #648 into master will increase coverage by 0.23%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master     #648      +/-   ##
==========================================
+ Coverage   35.11%   35.35%   +0.23%     
==========================================
  Files          68       68              
  Lines        7943     7915      -28     
  Branches     1889     1894       +5     
==========================================
+ Hits         2789     2798       +9     
+ Misses       4374     4341      -33     
+ Partials      780      776       -4
# [Codecov](https://codecov.io/gh/Plume-org/Plume/pull/648?src=pr&el=h1) Report > Merging [#648](https://codecov.io/gh/Plume-org/Plume/pull/648?src=pr&el=desc) into [master](https://codecov.io/gh/Plume-org/Plume/commit/28fb50438e53019d5bda97e3b2532e5831096c9e?src=pr&el=desc) will **increase** coverage by `0.23%`. > The diff coverage is `n/a`. ```diff @@ Coverage Diff @@ ## master #648 +/- ## ========================================== + Coverage 35.11% 35.35% +0.23% ========================================== Files 68 68 Lines 7943 7915 -28 Branches 1889 1894 +5 ========================================== + Hits 2789 2798 +9 + Misses 4374 4341 -33 + Partials 780 776 -4 ```
codecov[bot] reageerde 5 jaren geleden (Gemigreerd van github.com)

Codecov Report

Merging #648 into master will increase coverage by 0.23%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master     #648      +/-   ##
==========================================
+ Coverage   35.11%   35.35%   +0.23%     
==========================================
  Files          68       68              
  Lines        7943     7915      -28     
  Branches     1889     1894       +5     
==========================================
+ Hits         2789     2798       +9     
+ Misses       4374     4341      -33     
+ Partials      780      776       -4
# [Codecov](https://codecov.io/gh/Plume-org/Plume/pull/648?src=pr&el=h1) Report > Merging [#648](https://codecov.io/gh/Plume-org/Plume/pull/648?src=pr&el=desc) into [master](https://codecov.io/gh/Plume-org/Plume/commit/28fb50438e53019d5bda97e3b2532e5831096c9e?src=pr&el=desc) will **increase** coverage by `0.23%`. > The diff coverage is `n/a`. ```diff @@ Coverage Diff @@ ## master #648 +/- ## ========================================== + Coverage 35.11% 35.35% +0.23% ========================================== Files 68 68 Lines 7943 7915 -28 Branches 1889 1894 +5 ========================================== + Hits 2789 2798 +9 + Misses 4374 4341 -33 + Partials 780 776 -4 ```
igalic (Gemigreerd van github.com) heeft deze veranderingen 5 jaren geleden goedgekeurd
igalic (Gemigreerd van github.com) heeft een reactie achtergelaten

please ignore my rambling

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
igalic (Gemigreerd van github.com) reageerde 5 jaren geleden

this should be either a (cached?) constant, or a (cached?) config value

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();
igalic (Gemigreerd van github.com) reageerde 5 jaren geleden

while i understand that this is a simple operation, i don't think we need to do it every time

while i understand that this is a simple operation, i don't think we need to do it every time
igalic (Gemigreerd van github.com) reageerde 5 jaren geleden

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

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
requiem958 (Gemigreerd van github.com) beoordeeld 5 jaren geleden
@ -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
requiem958 (Gemigreerd van github.com) reageerde 5 jaren geleden

It should be a constant yes, but the rust doc of constant says :

Constants can be set only to a constant expression and not to the result of a function call or any other value that will be computed at runtime.

So i thought the keyword const was forbidden in this case.

It should be a constant yes, but the rust doc of constant says : > Constants can be set only to a constant expression and not to the result of a function call or any other value that will be computed at runtime. So i thought the keyword const was forbidden in this case.
trinity-1686a beoordeeld 5 jaren geleden
@ -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
Eigenaar

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

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

Reviewers

De pull request is samengevoegd als 935d331e97.
Je kunt ook command line instructies bekijken.

Stap 1:

Vanuit het project, check een branch uit en test de veranderingen.
git checkout -b issue-frontend-language master
git pull origin issue-frontend-language

Stap 2:

Voeg de wijzigingen samen en update ze op Forgejo.
git checkout master
git merge --no-ff issue-frontend-language
git push origin master
Log in om deel te nemen aan deze discussie.
Geen beoordelaars
Geen mijlpaal
Niet toegewezen
2 deelnemers
Notificaties
Vervaldatum
De deadline is ongeldig of buiten bereik. Gebruik het formaat 'jjjj-mm-dd'.

Geen vervaldatum ingesteld.

Afhankelijkheden

Geen afhankelijkheden ingesteld.

Referentie: Plume/Plume#648
Laden…
Er is nog geen inhoud.