8
16
Fork 22

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

Zusammengeführt
requiem958 hat 2 Commits von issue-frontend-language nach master vor 5 Jahren zusammengeführt
requiem958 hat vor 5 Jahren kommentiert (Migriert von 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] hat vor 5 Jahren kommentiert (Migriert von 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] hat vor 5 Jahren kommentiert (Migriert von 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 (Migriert von github.com) hat die Änderungen vor 5 Jahren genehmigt
igalic (Migriert von github.com) hat einen Kommentar hinterlassen

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 (Migriert von github.com) hat vor 5 Jahren kommentiert

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 (Migriert von github.com) hat vor 5 Jahren kommentiert

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 (Migriert von github.com) hat vor 5 Jahren kommentiert

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 (Migriert von github.com) hat vor 5 Jahren überprüft
@ -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 (Migriert von github.com) hat vor 5 Jahren kommentiert

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 hat vor 5 Jahren überprüft
@ -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
trinity-1686a hat vor 5 Jahren kommentiert
Besitzer

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

Reviewer

Der Pull Request wurde als 935d331e97 gemergt.

Schritt 1:

Wechsle auf einen neuen Branch in deinem lokalen Repository und teste die Änderungen.
git checkout -b issue-frontend-language master
git pull origin issue-frontend-language

Schritt 2:

Führe die Änderungen zusammen und aktualisiere den Stand online auf Forgejo.
git checkout master
git merge --no-ff issue-frontend-language
git push origin master
Anmelden, um an der Diskussion teilzunehmen.
Keine Reviewer
Kein Meilenstein
Niemand zuständig
2 Beteiligte
Nachrichten
Fällig am
Das Fälligkeitsdatum ist ungültig oder außerhalb des zulässigen Bereichs. Bitte verwende das Format „jjjj-mm-tt“.

Kein Fälligkeitsdatum gesetzt.

Abhängigkeiten

Keine Abhängigkeiten gesetzt.

Referenz: Plume/Plume#648
Laden…
Hier gibt es bis jetzt noch keinen Inhalt.