Skip to content

Unlocalized preferences new#8304

Closed
btut wants to merge 3 commits into
mainfrom
unlocalized-preferences-new
Closed

Unlocalized preferences new#8304
btut wants to merge 3 commits into
mainfrom
unlocalized-preferences-new

Conversation

@btut

@btut btut commented Dec 6, 2021

Copy link
Copy Markdown
Contributor

Currently, JabRef uses some localized preferences. Example: The entry editor offers a tab "Comments". This heading can be customized.

We want to remove the Localization-dependency from JabRefPreferences and move the Localization to where the string is used.

See ADR0023 for implementation details.

There is a first attempt and lots of discussion in #8050.

  • Change in CHANGELOG.md described in a way that is understandable for the average user (if applicable)
  • Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • Screenshots added in PR description (for UI changes)
  • Checked documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request to the documentation repository.

@btut

btut commented Dec 6, 2021

Copy link
Copy Markdown
Contributor Author

@koppor @calixtus @tobiasdiez I did not have much time to implement this yet, but changed one preference as an example. Would be great if you could cross-check if this is what we agreed on.
If it is, we can do the same for the other localized preferences. Otherwise, we make sure we are on the same page now when there is only one example to fix.

@tobiasdiez tobiasdiez left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Two suggestions to further improve it:

}

public void storeSettings() {
String eMailSubject = eMailReferenceSubjectProperty.getValue();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would move this to the storeExternalApplicationsPreferences method so that you don't need to expose the default value outside and have consistent behavior if some other code also needs to change the email subject.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you mean the whole comparison to the default value? That needs localization, if we leave that in storeExternalApplicationsPreferences we do not get rid of the localization dependence in the preferences.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's what I had in mind.

I don't think it's a bad thing per se if the JabRef preference class depends on the localization but that depends a bit on what you want to achieve: complety remove localization aspects form JabRef preferences or only remove localization of the stored preference values.

As a middle ground one could put the translation logic in ExternalApplicationsPreferences

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Target was to reduce JabRefPreferences to the bare minimum, so we can modularize the gui and the cli. So the fewer dependencies, the better.

defaults.put(KEY_GEN_FIRST_LETTER_A, Boolean.TRUE);
defaults.put(KEY_GEN_ALWAYS_ADD_LETTER, Boolean.FALSE);
defaults.put(EMAIL_SUBJECT, Localization.lang("References"));
defaults.put(EMAIL_SUBJECT, "References");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idea: since we now loose our nice localization tests that make sure that "References" should be translated, what do you think about adding a Localization.plan method that simply returns the string. Than one could change the localization tests to also look for plain in addition to lang . That would minimize the disadvantages even more I think.

@calixtus calixtus Dec 7, 2021

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't be Localization.plain("References") then always the same as "References"?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. The point was to still have the localization tests which could look for Localization.plain


public void setValues() {
eMailReferenceSubjectProperty.setValue(initialPreferences.getEmailSubject());
defaultEMailReferenceSubject = Localization.lang((String) preferences.getDefaults().get(JabRefPreferences.EMAIL_SUBJECT));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we already discussed in the DevCall, I'd say: Thou shall not access low level code directly from high level context. ;-)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So what do you propose we do instead? If we cannot access the translated default here, this approach won't work.

@calixtus calixtus Dec 19, 2021

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im thinking of completly different approach to defining defaults. Instead of working in the low level api of JabRefPreferences with the internal map strings, the defautls could be placed in another class DefaultPreferences which implements PreferencesServices.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this could be a solution for our localized preferences debate?

@Siedlerchr

Copy link
Copy Markdown
Member

Closing this issue due to inactivity 💤
Please reopen the issue with additional information if the problem persists.

@Siedlerchr Siedlerchr closed this Aug 18, 2023
@koppor koppor added the status: freeze Issues posponed to a (much) later future label Jun 19, 2024
@koppor koppor mentioned this pull request Oct 16, 2024
4 tasks
@koppor koppor deleted the unlocalized-preferences-new branch March 12, 2025 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: preferences status: freeze Issues posponed to a (much) later future

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants