scelis / twine

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

generate-localization-file include only strings without tags #291

Open nuke-dash opened 4 years ago

nuke-dash commented 4 years ago

I have a twine file with keys containing no tags and keys containing tags. e.g.

twine example
[[Guest Mode]]
    [guestMode_unavailable_on_guest_mode_popup_cancel_action]
        en = Cancel
        comment = Confirmation popup action "Cancel" to continue in guest mode
        sl = Cancel
[[Permissions]]
    [NSBluetoothAlwaysUsageDescription]
        en = ${PRODUCT_NAME} uses Bluetooth to discover nearby Cast devices.
        comment = iOS message shown to the user when using chomecast device discovery. PRODUCT_NAME is the name of the app
        tags = infoplist
        sl = ${PRODUCT_NAME} uses Bluetooth to discover nearby Cast devices.

I can't seem to get only the strings without tags. Getting only the infoPlist strings works with the following command: twine generate-localization-file ./twine.txt ./test.strings --lang en --format apple --tags infoplist

But using ~infoplist doesn't work $ twine generate-localization-file ./twine.txt ./test.strings --lang en --format apple --tags ~infoplist zsh: no such user or named directory: infoplist

Wrapping it inside double quotes also doesn't work $ twine generate-localization-file ./twine.txt ./test.strings --lang en --format apple --tags "~infoplist" Nothing to generate! The resulting file would not contain any translations.

Is it perhaps required that all field have tags when working with --tags? As I noticed that when I add the tag "common" to one of the strings without tags the command succeeds when using double quotes and contains only the one string. But I would expect it to also include the strings without tags.

scelis commented 4 years ago

Hello! Have you tried the --untagged option?

twine generate-localization-file ./twine.txt ./test.strings --lang en --format apple --untagged

nuke-dash commented 4 years ago

Thanks, I didn't knew that existed, the docs don't mention it. But unfortunately it doesn't seem to be working. It seems to also include strings with tags

$twine generate-localization-file ./twine.txt ./test.strings --lang en --format apple --untagged 
$cat ./test.strings
/**
 * Apple Strings File
 * Generated by Twine 1.0.6
 * Language: en
 */

/********** Guest Mode **********/

/* Confirmation popup action "Cancel" to continue in guest mode */
"guestMode_unavailable_on_guest_mode_popup_cancel_action" = "Cancel";

/********** Permissions **********/

/* iOS message shown to the user when using chomecast device discovery. PRODUCT_NAME is the name of the app */
"NSBluetoothAlwaysUsageDescription" = "${PRODUCT_NAME} uses Bluetooth to discover nearby Cast devices.";
scelis commented 4 years ago

A ha! Sorry, it's not super clear.

--tags is used to select tags you want, but if you don't specify anything twine assumes you want all tags (but not strings that are untagged)

--untagged is used to also select strings that are untagged

If you only specify untagged you get everything. Tagged and untagged.

So you really want to specify NO tag. Or a tag that doesn't exist. As well as untagged. So either of these should theoretically work:

twine generate-localization-file ./twine.txt ./test.strings --lang en --format apple --untagged --tags=""

twine generate-localization-file ./twine.txt ./test.strings --lang en --format apple --untagged --tags=AN_INVALID_TAG

I definitely think we could do something here to make this better and/or more obvious.