scelis / twine

Twine is a command line tool for managing your strings and their translations.
Other
840 stars 151 forks source link

Unable to parse line 2 of ../../mg/localization_all/strings.txt #299

Closed kirtigiripunje closed 2 years ago

kirtigiripunje commented 3 years ago

I was follow the guide line. link but has problem in android

Output:

sebastianludwig commented 3 years ago

Hey, please attach your strings.txt file. Thanks

kirtigiripunje commented 3 years ago

[[applevel]]     [name]         tags = ios,android         en-US = MG1         hi-IN = MG1         mr-IN = MG1         gu-IN = MG1         kn-IN = MG1         pa-IN = MG1         ta-IN = MG1         te-IN = MG1

sebastianludwig commented 3 years ago

Looks good.. 🤔 Does converting it "manually" on the command line work? I mean when you invoke twine yourself in a terminal?

kirtigiripunje commented 3 years ago

No i did not try but how to do that please let me know the syntax for same to try using terminal and create different language string.xml files. Is any way to implement simply in Android application. Previously it was work fine in Mac machine then I changed to windows machine, that time not work. now I am once again chack same project in mac machine now its not work

scelis commented 3 years ago

I wonder if there is an issue with text encoding or line endings. Can you try with a new file you create on your Mac itself? Just a basic one like the one you pasted above.

kirtigiripunje commented 3 years ago

Please check this below 2 command I was use to generate string file

String script = "if hash twine 2>/dev/null; then twine generate-localization-file ../../mg/localization_all/strings1.txt ./src/main/res/values/strings.xml --lang {$defaultLanguage} --format android --tags android; fi"

String script = 'if hash twine 2>/dev/null; then twine generate-all-localization-files ../../mg/localization_all/strings1.txt ./src/main/res/ -r --format android --tags android; fi'

Error:

Build file '/Users/kirtikumargiripunje/mg/app/build.gradle' line: 220

Execution failed for task ':app:generateStrings'.

Process 'command 'sh'' finished with non-zero exit value 1

Task :app:generateStrings FAILED Importing localized strings... Skipping file at path ./src/main/res/values/strings.xml since it would not contain any translations. Skipping file at path ./src/main/res/values-        gu-rIN/strings.xml since it would not contain any translations. Skipping file at path ./src/main/res/values-        hi-rIN/strings.xml since it would not contain any translations. Skipping file at path ./src/main/res/values-        kn-rIN/strings.xml since it would not contain any translations. Skipping file at path ./src/main/res/values-        mr-rIN/strings.xml since it would not contain any translations. Skipping file at path ./src/main/res/values-        pa-rIN/strings.xml since it would not contain any translations. Skipping file at path ./src/main/res/values-        ta-rIN/strings.xml since it would not contain any translations. Skipping file at path ./src/main/res/values-        te-rIN/strings.xml since it would not contain any translations. Set default string using configuration... Nothing to generate! The resulting file would not contain any translations.

strings1.txt

scelis commented 3 years ago

@kirtigiripunje I am not really familiar with how you are integrating twine with your Android build tasks. Twine is at its heart a command line tool and how you integrate it in build scripts is left as an exercise for the user. However, if a particular command is giving you trouble I am more than happy to help you with it but it would really help if you gave us the exact twine command you are running along with a replica of your strings.txt file so that we can understand what is going on.

kirtigiripunje commented 3 years ago

please check above 2 command

scelis commented 3 years ago

I am unable to reproduce using your strings.txt file:

~/tmp $ bundle exec twine --version
Twine version 1.1
~/tmp $ bundle exec twine generate-all-localization-files strings.txt res/ -r --format android --tags android
~/tmp $ cat res/values-gu-rIN/strings.xml 
<?xml version="1.0" encoding="utf-8"?>
<!-- Android Strings File -->
<!-- Generated by Twine 1.1 -->
<!-- Language: gu-IN -->
<resources>
    <!-- SECTION: applevel -->
    <string name="name">MG1</string>
</resources>
scelis commented 3 years ago

Oh, the strings1.txt file you uploaded above does not contain any tags on its single string. So selecting --tags android would cause no strings to be written.