| 121 | } |
| 122 | |
| 123 | void LocalisedStrings::loadFromText (const String& fileContents, bool ignoreCase) |
| 124 | { |
| 125 | translations.setIgnoresCase (ignoreCase); |
| 126 | |
| 127 | StringArray lines; |
| 128 | lines.addLines (fileContents); |
| 129 | |
| 130 | for (auto& l : lines) |
| 131 | { |
| 132 | auto line = l.trim(); |
| 133 | |
| 134 | if (line.startsWithChar ('"')) |
| 135 | { |
| 136 | auto closeQuote = findCloseQuote (line, 1); |
| 137 | auto originalText = unescapeString (line.substring (1, closeQuote)); |
| 138 | |
| 139 | if (originalText.isNotEmpty()) |
| 140 | { |
| 141 | auto openingQuote = findCloseQuote (line, closeQuote + 1); |
| 142 | closeQuote = findCloseQuote (line, openingQuote + 1); |
| 143 | auto newText = unescapeString (line.substring (openingQuote + 1, closeQuote)); |
| 144 | |
| 145 | if (newText.isNotEmpty()) |
| 146 | translations.set (originalText, newText); |
| 147 | } |
| 148 | } |
| 149 | else if (line.startsWithIgnoreCase ("language:")) |
| 150 | { |
| 151 | languageName = line.substring (9).trim(); |
| 152 | } |
| 153 | else if (line.startsWithIgnoreCase ("countries:")) |
| 154 | { |
| 155 | countryCodes.addTokens (line.substring (10).trim(), true); |
| 156 | countryCodes.trim(); |
| 157 | countryCodes.removeEmptyStrings(); |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | translations.minimiseStorageOverheads(); |
| 162 | } |
| 163 | |
| 164 | void LocalisedStrings::addStrings (const LocalisedStrings& other) |
| 165 | { |
nothing calls this directly
no test coverage detected