crowdin / crowdin-cli

A command-line client for the Crowdin API
https://crowdin.github.io/crowdin-cli
MIT License
244 stars 89 forks source link

What is the best practice for sources structure or config options in hybrid iOS/Android project #293

Closed pavelosipov closed 4 years ago

pavelosipov commented 4 years ago

I use crowdin to localize both iOS and Android app. At the same time, I integrated my project branches with CLI app (3.2.0), and resulting directory structure in crowdin looks like the following:

master
  |- values // Android resources
  |   |- Android
  |   |- some_strings.xml
  |- InfoPlist.strings // iOS
  |- Localizable.strings // iOS
  |- Localizable.stringsdict // iOS

The problem is the annoying warning which is impossible to hide when downloading translations for the iOS app "Due to missing respective sources, the following translations will be omitted":

crowdin download -l es-ES -b `git branch --show-current`
✔️  Fetching project info
✔️  Building ZIP archive with the latest translations for 'es-ES'
✔️  Building translation (100%)
✔️  Downloading translation
✔️  Extracted: 'Resources/Localization/es.lproj/AppStore.strings'
✔️  Extracted: 'Resources/Localization/es.lproj/Localizable.strings'
✔️  Extracted: 'Resources/Localization/es.lproj/Localizable.stringsdict'
✔️  Extracted: 'Resources/es.lproj/InfoPlist.strings'
⚠️  Due to missing respective sources, the following translations will be omitted:
    - values/strings.xml
    - values/some_strings.xml

How to hide it or may there is a more convenient way to separate resources in a multiplatform project. My configuration file:

"base_path": "."
"files": [
    {
        "source": "/Resources/Localization/en.lproj/*.strings",
        "translation": "/Resources/Localization/%osx_locale%.lproj/%original_file_name%",
    },
    {
        "source": "/Resources/Localization/en.lproj/*.stringsdict",
        "translation": "/Resources/Localization/%osx_locale%.lproj/%original_file_name%",
    },
    {
        "source": "/Resources/en.lproj/*.strings",
        "translation": "/Resources/%osx_locale%.lproj/%original_file_name%",
    }
]
og-fox commented 4 years ago

Hi @pavelosipov!

The message appears because the files are present in your Crowdin project, but are not listed in the crowdin.yml file, so CLI lets you know that there are some translations in the project that won't be downloaded this time. There is no way to remove this message from appearing as long as the files are mixed in the same directories :(

The idea that comes to mind is placing your iOS and Android files into the separate branches in Crowdin and use crowdin download -b {branch name} command to work with the appropriate branch in Crowdin. Your local files can still have the same structure and the config crowdin.yml files won't require any changes. The only change would be in Crowdin project structure and the command you will use. Would you please let me know if this sounds like a plan?

pavelosipov commented 4 years ago

Hi, @og-fox Thanks a lot for your quick response! Making branches with different prefixes for iOS and Android is a good enough solution for me. I thought about it but decided to prove that workaround before implementation.

og-fox commented 4 years ago

@pavelosipov, please accept my apologies for the delayed answer!

Separate branches are indeed the best scenario in this case and should work perfectly 🙂 Let me know if I can assist you with implementation!

pavelosipov commented 4 years ago

I still can't figure out how to merge translations in crowdin after merging source code in git. Let's consider the following situation:

  1. master-git branch and master-crowdin branch are in sync, and there are a and b keys in Localizable.strings
  2. r1-git appears in git followed by r1-crowdin branch in crowdin
  3. according to branch creation documentation crowdin upload sources -b r1-crowdin and crowdin upload translates -b r1-crowdin commands are executed
  4. Key c added to both r1-git and r1-crowdin branches and translated
  5. Key d added to both master-git and master-crowdin branches and translated
  6. r1-git merged back into master-git

The question: what is the right way to merge master-crowdin and r1-crowdin branches?

  1. I assume that key d will be removed In case of executing crowdin upload translates -b master-crowdin from r1-git branch. Am I right or not?
  2. If I'll not merge translates from r1-crowdin to master-crowdin at all then the key d will be absent in the next branch r2-git from master-git. Am I right or not?

So how to preserve both c and d keys in master-crowdin after merging r1-git into master-git?

Andrulko commented 4 years ago

@pavelosipov After you merge r1-git into master-git, you simply need to update master-crowdin branch with master-git branch content. As a result, master-crowdin will contain the same strings as r1-crowdin branch. Afterward, you can freely delete r1-crowdin branch from your Crowdin project. All translations you had in r1-crowdin will automatically migrate to master-crowdin during deletion.

❗ It is very important that you utilize Show (Recommended for Versions) option for duplicated strings in your Crowdin project settings. If it's not activated, migration of translations won't happen and there is a risk to lose some translations.

pavelosipov commented 4 years ago

Thank you for response, @Andrulko.

you simply need to update master-crowdin branch with master-git branch content

Does that mean the execution of command crowdin upload sources -b master-crowdin without following crowdin upload translates -b master-crowdin, because translates of unique sources in r1-crowdin will be somehow merged in master-crowdin by crowdin service itself right after the first command?

pavelosipov commented 4 years ago

Just found answers to all my questions in experimental trial account. Thank you, guys, for all your responses.

og-fox commented 4 years ago

@pavelosipov,

I'm sorry we didn't notice previous question! But I'm glad to hear that you found all the answers already :)

If there is anything else we might be able to assist you with, feel free to ping us!