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

Implemented conversions between JSON and Xcode files #7

Merged
merged 15 commits into from
Jun 12, 2024

Conversation

Jag-Marcel
Copy link
Member

@Jag-Marcel Jag-Marcel commented Jun 3, 2024

Description

This PR implements python scripts to convert between JSON files and Xcode's .xcstrings string catalogs and adds the current localizations from the iOS app to the existing JSONs.

Added the current localizations fetched from the iOS repo to the existing JSON files
Implemented a script that converts .xcstrings files to .json files. The JSON files use the template:
"key" : {
    "translation" : "translationValue",
    "comment" : "commentValue"
}
It requires the "requests" library to fetch the string catalog directly from the Scribe-iOS repo (there may be a better implementation of this)
Implemented a script that converts .json files to one .xcstrings file. It assumes that translated entries are already reviewed.
todo: Needs to be an automated process, maybe automatic PRs for Scribe-iOS whenever a JSON file in Scribe-i18n changes.
This reverts commit d452419.
Translations will be provided when they're finalized
New design puts the xcstrings file in the main directory, can be changed later
Copy link

github-actions bot commented Jun 3, 2024

Thank you for the pull request!

The Scribe team will do our best to address your contribution as soon as we can. The following is a checklist for maintainers to make sure this process goes as well as possible. Feel free to address the points below yourself in further commits if you realize that actions are needed :)

If you're not already a member of our public Matrix community, please consider joining! It'd be great to have you!

Maintainer checklist

  • The commit messages for the remote branch should be checked to make sure the contributor's email is set up correctly so that they receive credit for their contribution
    • The contributor's name and icon in remote commits should be the same as what appears in the PR
    • If there's a mismatch, the contributor needs to make sure that the email they use for GitHub matches what they have for git config user.email in their local activist repo

Adjusted the conversion because missing localizations would display as empty strings instead of key placeholders
This reverts commit 3de1788.
The changes broke compatibility with converting the xcstrings file back to python, instead the key now *is* the translated text to make sure it gets used as a placeholder.
The script is now in line with the idea that the Xcode string catalog will be in the Scribe-i18n directory. Unused translations have also been removed for now, so that users won't be able to select languages without any translations.
@Jag-Marcel Jag-Marcel marked this pull request as ready for review June 4, 2024 14:48
@andrewtavis andrewtavis linked an issue Jun 7, 2024 that may be closed by this pull request
2 tasks
Jag-Marcel and others added 4 commits June 8, 2024 15:13
- Changed name of scripts to say 'xcstrings' instead of 'swift'
- Added GitHub action that executes the conversion script to xcstrings as soon as a change to the JSON files gets pushed to the repo
- Added back previously removed JSON files
- JSONs will now work as agreed: simply key : value pairs
- xcstrings file now only has the most necessary info; both to simplify and shrink it, and to make sure missing translations get rendered with default values instead of empty strings or keys
runs-on: ubuntu-latest
needs:
- conditional_job_check_files
if: needs.conditional_job_check_files.outsputs.json_changed == 'True'
Copy link
Member

Choose a reason for hiding this comment

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

Just checking, but this should be outputs - i.e. extra s in the middle?

Copy link
Member

Choose a reason for hiding this comment

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

Was showing me an error on my end :)

Copy link
Member

Choose a reason for hiding this comment

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

We do need pt.json for the Portuguese localization :)

Copy link
Member

@andrewtavis andrewtavis left a comment

Choose a reason for hiding this comment

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

Let's look at this a bit more on Saturday, @Jag-Marcel! :) I did fix the minor things that I talked about in the comments. Let's discuss what we want the key naming criteria to be as a group, but feel free to start preparing the localization process in iOS as you see fit :)

@andrewtavis
Copy link
Member

Would be great if you'd present this, if you're comfortable 😊

@andrewtavis andrewtavis merged commit 06027db into scribe-org:main Jun 12, 2024
@Jag-Marcel Jag-Marcel deleted the swift-conversions branch June 13, 2024 12:50
@Jag-Marcel
Copy link
Member Author

Yes, I can present this at the next sync

@Jag-Marcel
Copy link
Member Author

@wkyoshida it looks like the changes here aren't automatically updated in the Scribe-iOS subtree, could you sync them when you have the time?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generate .xcstrings from Scribe-i18n files
2 participants