{
consume_all: {
switch: ['-a', '--[no-]consume-all'],
description: 'Normally Twine will ignore any translation keys that do not exist in your Twine file.',
boolean: true
},
consume_comments: {
switch: ['-c', '--[no-]consume-comments'],
description: " Normally Twine will ignore all comments in the file. With this flag set, any \n comments encountered will be read and parsed into the Twine data file. This is especially useful \n when creating your first Twine data file from an existing project.\n DESC\n boolean: true\n },\n create_folders: {\n switch: ['-r', '--[no-]create-folders'],\n description: <<-DESC,\n This flag may be used to create output folders for all languages, if they don't exist yet.\n As a result all languages will be exported, not only the ones where an output folder already exists.\n DESC\n boolean: true\n },\n developer_language: {\n switch: ['-d', '--developer-language LANG'],\n description: <<-DESC,\n When writing the Twine data file, set the specified language as the \"developer language\". In \n practice, this just means that this language will appear first in the Twine data file. When \n generating files this language will be used as default language and its translations will be \n used if a definition is not localized for the output language.\n DESC\n },\n encoding: {\n switch: ['-e', '--encoding ENCODING'],\n description: <<-DESC,\n Twine defaults to encoding all output files in UTF-8. This flag will tell Twine to use an alternate\n encoding for these files. For example, you could use this to write Apple .strings files in UTF-16. \n When reading files, Twine does its best to determine the encoding automatically. However, if the \n files are UTF-16 without BOM, you need to specify if it's UTF-16LE or UTF16-BE.\n DESC\n },\n file_name: {\n switch: ['-n', '--file-name FILE_NAME'],\n description: 'This flag may be used to overwrite the default file name of the format.'\n },\n format: {\n switch: ['-f', '--format FORMAT', ALL_FORMATS],\n description: <<-DESC,\n The file format to read or write: (\#{ALL_FORMATS.join(', ')}). Additional formatters can be placed in the formats/ directory.\n DESC\n },\n :include => {\n switch: ['-i', '--include SET', [:all, :translated, :untranslated]],\n description: <<-DESC,\n This flag will determine which definitions are included. It's possible values are:\n all: All definitions both translated and untranslated for the specified language are included. \n This is the default value.\n translated: Only definitions with translation for the specified language are included.\n untranslated: Only definitions without translation for the specified language are included.\n DESC\n default: :all\n },\n languages: {\n switch: ['-l', '--lang LANGUAGES', Array],\n description: 'Comma separated list of language codes to use for the specified action.'\n },\n output_path: {\n switch: ['-o', '--output-file OUTPUT_FILE'],\n description: 'Write a new Twine file at this location instead of replacing the original file.'\n },\n pedantic: {\n switch: ['-p', '--[no-]pedantic'],\n description: 'When validating a Twine file, perform additional checks that go beyond pure validity (like presence of tags).'\n },\n quiet: {\n switch: ['-q', '--[no-]quiet'],\n description: 'Suppress all console output except error messages.'\n },\n tags: {\n switch: ['-t', '--tags TAG1,TAG2,TAG3', Array],\n description: <<-DESC,\n Only definitions with ANY of the specified tags will be processed. Specify this option multiple\n times to only include definitions with ALL of the specified tags. Prefix a tag with ~ to include\n definitions NOT containing that tag. Omit this option to match all definitions in the Twine data file.\n DESC\n repeated: true\n },\n untagged: {\n switch: ['-u', '--[no-]untagged'],\n description: <<-DESC,\n If you have specified tags using the --tags flag, then only those tags will be selected. If you also \n want to select all definitions that are untagged, then you can specify this option to do so.\n DESC\n },\n validate: {\n switch: ['--[no-]validate'],\n description: 'Validate the Twine file before formatting it.'\n }\n}\n",
{
'generate-localization-file' => {
description: 'Generates a localization file in a certain LANGUAGE given a particular FORMAT. This script will attempt to guess both the language and the format given the filename and extension. For example, "ko.xml" will generate a Korean language file for Android.',
arguments: [:twine_file, :output_path],
optional_options: [
:developer_language,
:encoding,
:format,
:include,
:languages,
:quiet,
:tags,
:untagged,
:validate
],
option_validation: Proc.new { |options|
if options[:languages] and options[:languages].length > 1
raise Twine::Error.new 'specify only a single language for the `generate-localization-file` command.'
end
},
example: 'twine generate-localization-file twine.txt ko.xml --tags FT'
},
'generate-all-localization-files' => {
description: 'Generates all the localization files necessary for a given project. The parent directory to all of the locale-specific directories in your project should be specified as the INPUT_OR_OUTPUT_PATH. This command will most often be executed by your build script so that each build always contains the most recent translations.',
arguments: [:twine_file, :output_path],
optional_options: [
:create_folders,
:developer_language,
:encoding,
:file_name,
:format,
:include,
:quiet,
:tags,
:untagged,
:validate
],
example: 'twine generate-all-localization-files twine.txt Resources/Locales/ --tags FT,FB'
},
'generate-localization-archive' => {
description: 'Generates a zip archive of localization files in a given format. The purpose of this command is to create a very simple archive that can be handed off to a translation team. The translation team can unzip the archive, translate all of the strings in the archived files, zip everything back up, and then hand that final archive back to be consumed by the consume-localization-archive command.',
arguments: [:twine_file, :output_path],
required_options: [
:format
],
optional_options: [
:developer_language,
:encoding,
:include,
:quiet,
:tags,
:untagged,
:validate
],
example: 'twine generate-localization-archive twine.txt LocDrop5.zip --tags FT,FB --format android --lang de,en,en-GB,ja,ko'
},
'consume-localization-file' => {
description: 'Slurps all of the translations from a localization file into the specified TWINE_FILE. If you have some files returned to you by your translators you can use this command to incorporate all of their changes. This script will attempt to guess both the language and the format given the filename and extension. For example, "ja.strings" will assume that the file is a Japanese iOS strings file.',
arguments: [:twine_file, :input_path],
optional_options: [
:consume_all,
:consume_comments,
:developer_language,
:encoding,
:format,
:languages,
:output_path,
:quiet,
:tags
],
option_validation: Proc.new { |options|
if options[:languages] and options[:languages].length > 1
raise Twine::Error.new 'specify only a single language for the `consume-localization-file` command.'
end
},
example: 'twine consume-localization-file twine.txt ja.strings'
},
'consume-all-localization-files' => {
description: 'Slurps all of the translations from a directory into the specified TWINE_FILE. If you have some files returned to you by your translators you can use this command to incorporate all of their changes. This script will attempt to guess both the language and the format given the filename and extension. For example, "ja.strings" will assume that the file is a Japanese iOS strings file.',
arguments: [:twine_file, :input_path],
optional_options: [
:consume_all,
:consume_comments,
:developer_language,
:encoding,
:format,
:output_path,
:quiet,
:tags
],
example: 'twine consume-all-localization-files twine.txt Resources/Locales/ --developer-language en --tags DefaultTag1,DefaultTag2'
},
'consume-localization-archive' => {
description: 'Consumes an archive of translated files. This archive should be in the same format as the one created by the generate-localization-archive command.',
arguments: [:twine_file, :input_path],
optional_options: [
:consume_all,
:consume_comments,
:developer_language,
:encoding,
:format,
:output_path,
:quiet,
:tags
],
example: 'twine consume-localization-archive twine.txt LocDrop5.zip'
},
'validate-twine-file' => {
description: 'Validates that the given Twine file is parseable, contains no duplicates, and that no key contains invalid characters. Exits with a non-zero exit code if those criteria are not met.',
arguments: [:twine_file],
optional_options: [
:developer_language,
:pedantic,
:quiet
],
example: 'twine validate-twine-file twine.txt'
}
}