-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Fix syncLangPy script #3743
Fix syncLangPy script #3743
Conversation
Thanks a lot! |
EscapingsLook at this: English file:
I think, one has to rewrite the English file to NOT escape Empty TranslationsEmpty strings must not be added, because of the new Crowdin workflow. Alternative: Add English as default (and not the empty ones) |
Does this run with jython? |
All of the code related to python 3 is within a try block. This keeps it's compatibility to python2, so it should be no problem to run it with jython. By the way there is already a repository for a jython version which is compatible to python 3.5 here: |
@koppor In order to fix the issue with the escapings, I think I have to rework the logging output first. The output is currently not helpful at all, which is just printing a lot of unreadable spam into the console. Once this is fixed it will be much easier to see which keys are causing some trouble during the merging process. |
Quick update: |
@koppor I think the script is now good to go. Due to my changes in the logging functionality, I found out all malformed strings will be replaced by the correct ones but they have to be translated again, unless the formatting is corrected manually (I think there are "only" 5 malformed keys in the german file, which should be done quickly). The command-line options are still working exactly the same as before but I also added a new option called print. This option allows to print specific status information for one particular file. Examples: Would you mind testing the latest version and let me know if you still want to have any changes? |
That comes right in time for checking the localization on the maintable beta branch! |
Otherwise, it looks good to me. Have to change the Crowdin config then. @JabRef/developers JabRef will now contain values (the english text!) for each translation in the non-English files. This is supported by Crowdin. |
Ok, I changed the print command. The file argument is no longer required for all subcommands (missing, obsolete, duplicates). You can now use |
@koppor I have the vague memory that we already discussed the problematic of having English as the default value for the other language and decided against this option because it would make the established way of editing the language files directly more difficult. Not sure how relevant this still is because every translation contribution now seems to come through crowdin. |
@tobiasdiez I think, it was only because we could not recognize easily with the script that the keys have been translated. For instance, following line
Is this translated or not? (In German yes, in Chinese not.) IMHO this is the edge case. With the change that the English values come into the other language files we enable the guys NOT working with Crowdin to be able to translate. For instance, @josephace135 wants to use GitHub to get rewarded via https://utopian.io. |
@Brainsucker92 Is it easily possible to add test cases for Python? It would be really great to test following: Translated:
Not translated:
These are the strings, I would look up manually and think whether they work. One can document code by adding test cases. And it would be really great if we had that for our syncLang.py script, too. |
@Brainsucker92 forget about that test cases. We keep the non-translated strings removed. Reason: IntelliJ can perfectly deal with it: |
@Brainsucker92 I am sorry to say, but could you remove the functionality to add missing keys in the other language files? Reporting etc. is OK, but not the addition... Reason: I find non-existing lines better than existing lines with strings from other languages. |
Sure, I can do that. But i think i'll do some other changes as well. The |
Sorry for the delay. I was working on another improvement of the script but due to upcoming exams I think I won't be able to complete the improvement any time soon. So I simply uploaded the change you requested. |
Hi, I just tried to run your script from gradle under Windows and got (apart for the missing python 3 exception): Actually it fails already with da_properties
|
Thanks for the hint. Should be fixed now, try again. |
I fixed it myway (I switched to my Pyhton 3 installation) if key is not None:
# Do not write empty keys
if keys.get(key) != "" and keys.get(key) is not None:
other_lines_to_write.append(Keys.format_key_and_value(key=key, value=keys[key]) + "\n")
else: That worked for me. However, no keys are copied to my empty properties. Only newlines and comments.
Just create a new empty property file: => No keys are inserted Or is this expected and managed by crowdin? https://stackoverflow.com/questions/33727149/dict-object-has-no-attribute-has-key |
Yes, because that's what @koppor requested to change.
That's what I did. All you have to do to revert this change is to uncomment lines 448 and 450. |
Okay: I have an idea. After I found out that missing properties make JabRef crash (Those keys that are used in the fxml files) it would be wise to either auto add these ones. Or you just could add an additional gradle task to add the missing keys. |
To be honest: In my opinion we should seriously consider rewriting the whole script to java, if there is no specific reason not to do this. The more changes are made on the script and the more functionality we add, the more complex the script becomes. And at some point python is no longer a viable language because it's primarily well suited for small and simple code which is slowly but surely overextended. Rewriting into Java would also solve any compatibility problems with py2.x and py3, and also get rid of any jython requirement for the whole JabRef project (if there is no other python code in use). |
Yes, that sounds like a valid reasonable thing. I think for the moment we can keep it as is and we should discuss this in the next devcall. |
@tobiasdiez Is it really true that JabRef crashes due to missing keys? I thought, you wrote a comment at some other place that this is not really the case and this can be fixed. I would like to keep the files clean. Now that utopian allows for having crowdin as platform to get Steem Coins, I would say, we do not need to change our workflow and let the language files be lean and clean. Especially because of the issue |
I tried to collect the options using MADR 2.0.1 Only translated strings in language fileContext and Problem StatementJabRef has translation files Decision Drivers
Considered Options
Decision OutcomeChosen option: "Only translated strings in language file", because comes out best (see below. Pros and Cons of the OptionsOnly translated strings in language file
Translated and untranslated strings in language file, have value the untranslated string to indicate untranslated
Translated and untranslated strings in language file, have empty to indicate untranslated
|
I just merged to move things forward, but the discussion on the options is not finalized. |
I think, we need the script if Crowdin changes its policy or vanishes from the market. In all other cases, our current workflow should be "good enough"? We can add new English language keys (by following the output of the failing tests). These are then synced to Crowdin. After a translator translated something, it goes into JabRef as pull request. Nevertheless, it is nice to have and other projects may benefit from it. Thus, a pip package (and thus a separate repo) might be the way to go. |
Regarding the FXML issues, @tobiasdiez fixed that in #3820 |
Fixes #3573
As already mentioned in my comment here: #3573 (comment)
there was a logical issue hidden within the merging process when synchronizing the files. I fixed this issue and added/changed a couple of other things.
in running JabRef