Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Localized Preferences revisited #11988

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 32 additions & 5 deletions docs/decisions/0023-localized-preferences.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Localized Preferences

* Status: proposed
* Date: 2021-09-01
* Date: 2024-10-16

## Context and Problem Statement

Expand All @@ -14,10 +14,37 @@

## Considered Options

* _Localize Defaults_ (current implementation)
* _Store the Preference only when it was changed by the user_. Otherwise, leave it empty. When a consumer gets such an empty preference, it knows that it needs to read the default and localize it. This won't work if users actually want something to be empty.
* _Store the unlocalized String._ Consumers then check the String they got as a preference against the defaults. If it matches, localize it. Otherwise, use it.
* Localize Defaults
* Store the preference only when it was changed by the user
* Store the unlocalized string
* Mark default value with `%`

## Decision Outcome

Chosen option: "_Store the unlocalized String._ Consumers then check the String they got as a preference against the defaults. If it matches, localize it. Otherwise, use it.", because Achieves goals without requiring too much refactoring and without (known) downsides.
Chosen option: "Mark default value with `%`", because it achieves goals without requiring too much refactoring and reuses a pattern already in use.

## Considered Options

Check failure on line 26 in docs/decisions/0023-localized-preferences.md

View workflow job for this annotation

GitHub Actions / Markdown

Multiple headings with the same content

docs/decisions/0023-localized-preferences.md:26 MD024/no-duplicate-heading Multiple headings with the same content [Context: "Considered Options"] https://github.com/DavidAnson/markdownlint/blob/v0.35.0/doc/md024.md

### Localize Defaults

* Good, because it is the current implementaton

### Store the pPreference only when it was changed by the user

Otherwise, leave it empty. When a consumer gets such an empty preference, it knows that it needs to read the default and localize it.

- Bad, because this won't work if users actually want something to be empty.

Check failure on line 36 in docs/decisions/0023-localized-preferences.md

View workflow job for this annotation

GitHub Actions / Markdown

Unordered list style

docs/decisions/0023-localized-preferences.md:36:1 MD004/ul-style Unordered list style [Expected: asterisk; Actual: dash] https://github.com/DavidAnson/markdownlint/blob/v0.35.0/doc/md004.md

### Store the unlocalized string

Consumers then check the string they got as a preference against the defaults. If it matches, localize it. Otherwise, use it.

### Mark default value with `%`

If user stores value, the value is stored as is.
The default value is stored with `%` in front.
A caller has to localize any stored value in the preferences if the string is 'escaped' by `%` as the first character

- Good, because clear distinction between default value and user-supplied value

Check failure on line 48 in docs/decisions/0023-localized-preferences.md

View workflow job for this annotation

GitHub Actions / Markdown

Unordered list style

docs/decisions/0023-localized-preferences.md:48:1 MD004/ul-style Unordered list style [Expected: asterisk; Actual: dash] https://github.com/DavidAnson/markdownlint/blob/v0.35.0/doc/md004.md
- Good, because on update of JabRef's defaults, the string is not modified

Check failure on line 49 in docs/decisions/0023-localized-preferences.md

View workflow job for this annotation

GitHub Actions / Markdown

Unordered list style

docs/decisions/0023-localized-preferences.md:49:1 MD004/ul-style Unordered list style [Expected: asterisk; Actual: dash] https://github.com/DavidAnson/markdownlint/blob/v0.35.0/doc/md004.md
- Good, because already used in fxml files to indicate translateable strings.

Check failure on line 50 in docs/decisions/0023-localized-preferences.md

View workflow job for this annotation

GitHub Actions / Markdown

Unordered list style

docs/decisions/0023-localized-preferences.md:50:1 MD004/ul-style Unordered list style [Expected: asterisk; Actual: dash] https://github.com/DavidAnson/markdownlint/blob/v0.35.0/doc/md004.md
Loading