From ebe50c3adc9ef2fd78519f16f5d3d23c2b782894 Mon Sep 17 00:00:00 2001 From: Dwayne Bailey Date: Thu, 8 Aug 2024 11:46:17 +0100 Subject: [PATCH] Use tab indents in iPhone plural stringdict files 2*sp -> \t Remove the confusingly named tab() that indents with spaces and use \t directly --- lib/twine/formatters/apple_plural.rb | 30 ++++++++++++---------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/lib/twine/formatters/apple_plural.rb b/lib/twine/formatters/apple_plural.rb index 422a5e0..47a2db2 100644 --- a/lib/twine/formatters/apple_plural.rb +++ b/lib/twine/formatters/apple_plural.rb @@ -37,21 +37,21 @@ module Twine end def format_plural_keys(key, plural_hash) - result = "#{tab(2)}#{key}\n" - result += "#{tab(2)}\n" - result += "#{tab(4)}NSStringLocalizedFormatKey\n" - result += "#{tab(4)}\%\#@value@\n" - result += "#{tab(4)}value\n" - result += "#{tab(4)}\n" - result += "#{tab(6)}NSStringFormatSpecTypeKey\n" - result += "#{tab(6)}NSStringPluralRuleType\n" - result += "#{tab(6)}NSStringFormatValueTypeKey\n" - "#{tab(6)}d\n" + result = "\t#{key}\n" + result += "\t\n" + result += "\t\tNSStringLocalizedFormatKey\n" + result += "\t\t\%\#@value@\n" + result += "\t\tvalue\n" + result += "\t\t\n" + result += "\t\t\tNSStringFormatSpecTypeKey\n" + result += "\t\t\tNSStringPluralRuleType\n" + result += "\t\t\tNSStringFormatValueTypeKey\n" + result += "\t\t\td\n" # Replace Android's %s with iOS %@ - result += plural_hash.map{|quantity,value| "#{tab(6)}#{quantity}\n#{tab(6)}#{convert_placeholders_from_android_to_twine(value)}"}.join("\n") + result += plural_hash.map{|quantity,value| "\t\t\t#{quantity}\n\t\t\t#{convert_placeholders_from_android_to_twine(value)}"}.join("\n") result += "\n" - result += "#{tab(4)}\n" - result += "#{tab(2)}\n" + result += "\t\t\n" + result += "\t\n" end def format_comment(definition, lang) @@ -62,10 +62,6 @@ module Twine raise NotImplementedError.new("Reading \".stringdict\" files not implemented yet") end - def tab(level) - ' ' * level - end - def should_include_definition(definition, lang) return definition.is_plural? && definition.plural_translation_for_lang(lang) end