PocketByte / LocoLaser

Localization tool to import localized strings from external source to your project.
Apache License 2.0
31 stars 1 forks source link

Kotlin Multiplatform - prevent base resource files overwrite #15

Closed gswierczynski closed 3 years ago

gswierczynski commented 3 years ago

Hi,

First of all thanks for a great tool.

I have incorporated it in my KMM project. I wonder if there is a way to prevent the overwrite of the:

My current config file looks like this:

{
  "platform": [
    {
      "type": "android",
      "res_dir": "../app/src/main/res/"
    },
    {
      "type": "ios",
      "res_dir": "../iosApp/iosApp/"
    },
    {
      "type": "kotlin-common",
      "res_dir": "./build/generated/locolaser/common/"
    },
    {
      "type": "kotlin-android",
      "res_dir": "./build/generated/locolaser/android/"
    },
    {
      "type": "kotlin-ios",
      "res_dir": "./build/generated/locolaser/ios/"
    }
  ],
  "source": "null",
  "temp_dir": "./build/temp/",
  "duplicate_comment":true
}

After running :localize the files mentioned above are overwritten (for example Localizable.stringsdict is overwritten with 'f' instead of 'd' for NSStringFormatValueTypeKey which is causing Plural to stop working properly on iOS) apart from this issue I would prefer to keep full control over those files.

What I am after is only generation of the KMM interface and platform implementations of that interface based on the files that I already have in project (values/strings.xml for Android and Base.lproj/Localizable.strings, Base.lproj/Localizable.stringsdict for iOS).

Hopefully I am just missing something from the configuration.

Thanks.

gswierczynski commented 3 years ago

I've tried putting android as a source and removing both android and ios from platform like this:

"source": {
      "type": "android",
      "res_dir": "../app/src/main/res/"
    }

But this resulted in build error: Invalid Config! Unknown source: android

KamiSempai commented 3 years ago

Which version of LocoLaser do you use? Usage android as a source available only since version 2.0.0. Please, look on latest example. May be it will help you https://github.com/PocketByte/locolaser-kotlin-mpp-example/blob/master/common/localize_config.json

Also, please look on migration notes to version 2.0.0 https://github.com/PocketByte/LocoLaser/blob/master/docs/migration.md

Any way, replacing 'd' by 'f' looks like a bug. Could you send me those plural strings that corrupts by LocoLaser? I need strings for both platforms, android and iOS.

gswierczynski commented 3 years ago

Hi @KamiSempai,

Thanks for your reply. From what I see I was using 1.4.0. Thank you for pointing that out. 2.0.0 works like a charm and since it is no longer touching source files the issue with 'd'/'f' for me is non-existent. Nevertheless here are example two files. locolizer_plural_example.zip Let me know if this is what you wanted.

KamiSempai commented 3 years ago

Great! The issue is not reproduce on latest version. Closing issue.

gswierczynski commented 3 years ago

Just a note. I probably do not fully comprehend all the ways Locolaser is used. If there is a scenario where someone is sourcing strings from android and outputing them for iOS then the 'f' instead of 'd' in the iOS plurals file issue might still be troublesome.

KamiSempai commented 3 years ago

Fixed in version 2.1.0. @gswierczynski please, don't forget to migrate to maven central. See instruction here https://github.com/PocketByte/locolaser-ios-example#migration-from-jcenter-to-maven-central