Skip to content

Commit

Permalink
fix: language settings parsing (#229)
Browse files Browse the repository at this point in the history
* Fix language settings parsing

`push.apply` should have two arguments, namely the two arrays to be pushed together. Much simpler and clearer to use regular push with `...`. Now the user's settings are finally used

* Update preferences.ftl

* Fix lint and add changelog

---------

Co-authored-by: Northword <northword@outlook.com>
  • Loading branch information
thebluepotato and northword authored Sep 28, 2024
1 parent 1c9625b commit adc86f3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- Fix language settings parsing, by @thebluepotato in [#229](https://github.com/northword/zotero-format-metadata/pull/229).

## [1.18.6] - 2024-09-15

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion addon/locale/en-US/preferences.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ language-fill-option-only-cmn =
language-fill-option-only-eng =
.label = English (en)
language-fill-option-only-other = and:
language-fill-option-only-other-desc = Here you need to enter the ISO 639-1 language code, separated by a semi-colon comma.
language-fill-option-only-other-desc = Enter a comma-separated list of additional ISO 639-1 language codes.
language-fill-option-only-other-doc = ISO 639-1 code
.href = https://github.com/northword/zotero-format-metadata#readme
Expand Down
3 changes: 1 addition & 2 deletions src/utils/str.ts
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,7 @@ export function getTextLanguage(text: string) {
if (getPref("lang.only.cmn")) options.only.push("zh");
if (getPref("lang.only.eng")) options.only.push("en");
const otherLang = getPref("lang.only.other") as string;
if (otherLang !== "" && otherLang !== undefined)
options.only.push.apply(otherLang.replace(/ /g, "").split(","));
if (otherLang !== "" && otherLang !== undefined) options.only.push(...otherLang.replace(/ /g, "").split(","));
}
ztoolkit.log("[lang] Selected ISO 639-1 code is: ", options.only);

Expand Down

0 comments on commit adc86f3

Please sign in to comment.