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

マージ済み
requiem958 が 2 個のコミットを issue-frontend-language から master へマージ 5年前
requiem958 がコメント 5年前 (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] がコメント 5年前 (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] がコメント 5年前 (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 (github.comから移行) が変更を承認 5年前
igalic (github.comから移行) がコメント

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 (github.comから移行) がコメント 5年前

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 (github.comから移行) がコメント 5年前

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 (github.comから移行) がコメント 5年前

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 (github.comから移行) がレビュー 5年前
@ -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 (github.comから移行) がコメント 5年前

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 がレビュー 5年前
@ -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 がコメント 5年前
オーナー

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

レビューア

プルリクエストは 935d331e97 でマージされています。
コマンドラインの手順も確認できます。

ステップ 1:

あなたのプロジェクトリポジトリで新しいブランチをチェックアウトし、変更内容をテストします。
git checkout -b issue-frontend-language master
git pull origin issue-frontend-language

ステップ 2:

変更内容をマージして、Forgejoに反映します。
git checkout master
git merge --no-ff issue-frontend-language
git push origin master
サインインしてこの会話に参加。
レビューアなし
マイルストーンなし
担当者なし
2 人の参加者
通知
期日
期日が正しくないか範囲を超えています。 'yyyy-mm-dd' の形式で入力してください。

期日は未設定です。

依存関係

依存関係が設定されていません。

リファレンス: Plume/Plume#648
読み込み中…
まだ内容がありません