Skip to content

Fix localization task hints #2031

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

Merged
merged 4 commits into from
Sep 25, 2016
Merged

Fix localization task hints #2031

merged 4 commits into from
Sep 25, 2016

Conversation

chriba
Copy link
Contributor

@chriba chriba commented Sep 22, 2016

fixes: #2029

Replaces hints to the old gradle localization task names with the new ones.

@boceckts boceckts added status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers and removed stupro-ready-for-internal-review labels Sep 22, 2016
Copy link
Member

@matthiasgeiger matthiasgeiger left a comment

Choose a reason for hiding this comment

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

see comments

@@ -156,7 +156,7 @@ public void findObsoleteLocalizationKeys() throws IOException {
System.out.println();
System.out.println("1. CAREFULLY CHECK IF THE KEY IS REALLY NOT USED ANYMORE");
System.out.println("2. REMOVE THESE FROM THE ENGLISH LANGUAGE FILE");
System.out.println("3. EXECUTE gradlew -b localization.gradle generateMissingTranslationKeys TO");
System.out.println("3. EXECUTE gradlew update");
Copy link
Member

Choose a reason for hiding this comment

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

This should be gradlew -b localization.gradle update, right?

Copy link
Contributor Author

@chriba chriba Sep 22, 2016

Choose a reason for hiding this comment

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

Nope, localization.gradle is imported in the build.gradle file, thus gradle knows the tasks form localization.gradle too.

@@ -172,7 +172,7 @@ public void findObsoleteMenuLocalizationKeys() throws IOException {
System.out.println(obsoleteKeys.stream().map(Object::toString).collect(Collectors.joining("\n")));
System.out.println();
System.out.println("1. REMOVE THESE FROM THE ENGLISH LANGUAGE FILE");
System.out.println("2. EXECUTE gradlew -b localization.gradle generateMissingTranslationKeys" + " TO");
System.out.println("3. EXECUTE gradlew update");
Copy link
Member

Choose a reason for hiding this comment

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

same as above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

see above, but fixed wrong item enumeration.

@@ -197,7 +198,7 @@ private String convertToEnglishPropertiesFile(List<LocalizationEntry> missingKey
}

private String convertPropertiesFile(List<LocalizationEntry> missingKeys) {
System.out.println("EXECUTE gradlew -b localization.gradle generateMissingTranslationKeys TO");
System.out.println("EXECUTE gradlew update");
Copy link
Member

Choose a reason for hiding this comment

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

same as above

@@ -85,7 +85,7 @@ because <additional rationale>.
Add new Localization.lang("KEY") to Java file.
Tests fail. In the test output a snippet is generated which must be added to the English translation file. There is also a snippet generated for the non-English files, but this is irrelevant.
Add snippet to English translation file located at `src/main/resources/l10n/JabRef_en.properties`
With `gradlew generateMissingTranslationKeys` the "KEY" is added to the other translation files as well.
With `gradlew update` the "KEY" is added to the other translation files as well.
Copy link
Member

Choose a reason for hiding this comment

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

Hm, I don't like the current task name. It should say what it does, like updateLocalization. Please also change the other Gradle tasks accordingly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right. I use the gradle tasks out of IntelliJ IDEA which groups them by its category.
I added localization as a prefix to each of them.

Copy link
Member

Choose a reason for hiding this comment

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

I also use them that way, thats the reason why I only realized this problem when looking at the PR code.

@@ -172,7 +172,7 @@ public void findObsoleteMenuLocalizationKeys() throws IOException {
System.out.println(obsoleteKeys.stream().map(Object::toString).collect(Collectors.joining("\n")));
System.out.println();
System.out.println("1. REMOVE THESE FROM THE ENGLISH LANGUAGE FILE");
System.out.println("3. EXECUTE gradlew update");
System.out.println("2. EXECUTE gradlew localizationUpdate");
Copy link
Member

Choose a reason for hiding this comment

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

If you already touch the localization tests, could you also remove the System.out.println statements by moving everything to the error message.
So for example this here should be
assertEquals("Obsolte kyes found in menu properties file. \n 1. Remove these... \n 2...", emptyList, obsolteKeys)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Member

@tobiasdiez tobiasdiez left a comment

Choose a reason for hiding this comment

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

Looks good and can be merged. Just fix the emptyList thing before.

missingKeys.parallelStream()
.map(key -> String.format("%s=%s", key.getKey(), key.getKey()))
.collect(Collectors.toList()),
Collections.EMPTY_LIST, missingKeys);
Copy link
Member

Choose a reason for hiding this comment

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

Collections.emptyList() is the preferred way to access it (don't ask me why).

Copy link
Contributor Author

@chriba chriba Sep 23, 2016

Choose a reason for hiding this comment

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

The advantage of Collections.EMPTY_LIST is that this list is immutable.
Collections.emptyList() is also immutable.

Copy link
Member

Choose a reason for hiding this comment

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

Collections.emptyList() is better because it is a generic implementatin! The constant is not generic

Copy link
Member

Choose a reason for hiding this comment

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

And it's also immuntable: https://docs.oracle.com/javase/8/docs/api/java/util/Collections.html#emptyList--
(Unlike this method, the field does not provide type safety.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I changed the lists.

@@ -128,7 +128,7 @@ public void findMissingLocalizationKeys() throws IOException {
missingKeys.parallelStream()
.map(key -> String.format("%s=%s", key.getKey(), key.getKey()))
.collect(Collectors.toList()),
Collections.EMPTY_LIST, missingKeys);
Collections.<LocalizationEntry>emptyList(), missingKeys);
Copy link
Member

Choose a reason for hiding this comment

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

Just for the future, you could have just taken the Collections.emptyList() without specifying the type explicit.

Copy link
Member

@Siedlerchr Siedlerchr left a comment

Choose a reason for hiding this comment

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

Okay, now looks good!
Failing test is not related

@koppor koppor merged commit 3481130 into JabRef:master Sep 25, 2016
@chriba chriba deleted the fixLocalizationTaskHint branch September 25, 2016 10:01
Siedlerchr added a commit that referenced this pull request Sep 25, 2016
* upstream/master:
  Implemented Integrity NoBibtexFieldChecker (#2059)
  Implemented title and camel key modifiers (#1894)
  Fix localization task hints (#2031)
  Result of syncLang.py update
  Result of syncLang.py update (with manual correction of captial_letters, and The_BibTeX_entry...)
  Fix "large capitals" to "capital letters"
  Updated Menu_tr.properties (#2057)
  Updated jabref_tr.properties (#2056)
  fix ignore version (#2055)
  Towards hierarchical keywords (#1950)
  Fix failing test, replace \uxxx encoded chars with proper UTF8 chars.
  Import Italian patch
zesaro pushed a commit to zesaro/jabref that referenced this pull request Nov 22, 2016
* fixLocalizationTaskHint
* added prefix to each of the gradle task names
* replace system.out with asserts in localization tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Localization tests refer to nonexistant Gradle tasks
7 participants