MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / loadFromText

Method loadFromText

JUCE/modules/juce_core/text/juce_LocalisedStrings.cpp:123–162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

121}
122
123void 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
164void LocalisedStrings::addStrings (const LocalisedStrings& other)
165{

Callers

nothing calls this directly

Calls 13

findCloseQuoteFunction · 0.85
unescapeStringFunction · 0.85
setIgnoresCaseMethod · 0.80
addLinesMethod · 0.80
startsWithCharMethod · 0.80
startsWithIgnoreCaseMethod · 0.80
addTokensMethod · 0.80
removeEmptyStringsMethod · 0.80
trimMethod · 0.45
substringMethod · 0.45
isNotEmptyMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected