Class: I18nContextGenerator::Parsers::StringsParser
- Defined in:
- lib/i18n_context_generator/parsers/strings_parser.rb
Overview
Parser for Apple .strings files (iOS/macOS) Uses the dotstrings gem for proper parsing with support for:
- Multi-line comments
- Unicode and escaped characters
- Proper error handling
Instance Method Summary collapse
Methods inherited from Base
Instance Method Details
#parse(path) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/i18n_context_generator/parsers/strings_parser.rb', line 11 def parse(path) # Use non-strict mode to be lenient with edge cases strings_file = DotStrings.parse_file(path, strict: false) strings_file.items.map do |item| TranslationEntry.new( key: item.key, text: item.value, source_file: path, metadata: { comment: item.comment } ) end rescue DotStrings::ParsingError => e raise Error, "Failed to parse .strings file #{path}: #{e.}" end |