|
|
@ -37,24 +37,29 @@ String _escapeXml(String xml) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Processes the XML files.
|
|
|
|
/// Processes the XML files.
|
|
|
|
Future<void> englishArbsToXmls() async {
|
|
|
|
Future<void> englishArbsToXmls({bool isDryRun = false}) async {
|
|
|
|
|
|
|
|
IOSink output =
|
|
|
|
|
|
|
|
isDryRun ? stdout : File('$_l10nDir/intl_en_US.xml').openWrite();
|
|
|
|
await generateXmlFromArb(
|
|
|
|
await generateXmlFromArb(
|
|
|
|
inputArb: File('$_l10nDir/intl_en_US.arb'),
|
|
|
|
inputArb: File('$_l10nDir/intl_en_US.arb'),
|
|
|
|
outputXml: File('$_l10nDir/intl_en_US.xml'),
|
|
|
|
outputXml: output,
|
|
|
|
xmlHeader: _intlHeader,
|
|
|
|
xmlHeader: _intlHeader,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
await output.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@visibleForTesting
|
|
|
|
@visibleForTesting
|
|
|
|
Future<void> generateXmlFromArb({
|
|
|
|
Future<void> generateXmlFromArb({
|
|
|
|
File inputArb,
|
|
|
|
File inputArb,
|
|
|
|
File outputXml,
|
|
|
|
IOSink outputXml,
|
|
|
|
String xmlHeader,
|
|
|
|
String xmlHeader,
|
|
|
|
}) async {
|
|
|
|
}) async {
|
|
|
|
final Map<String, dynamic> bundle = jsonDecode(await inputArb.readAsString());
|
|
|
|
final Map<String, dynamic> bundle =
|
|
|
|
|
|
|
|
jsonDecode(await inputArb.readAsString()) as Map<String, dynamic>;
|
|
|
|
|
|
|
|
|
|
|
|
String translationFor(String key) {
|
|
|
|
String translationFor(String key) {
|
|
|
|
assert(bundle[key] != null);
|
|
|
|
assert(bundle[key] != null);
|
|
|
|
return _escapeXml(bundle[key]);
|
|
|
|
return _escapeXml(bundle[key] as String);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
final xml = StringBuffer(xmlHeader);
|
|
|
|
final xml = StringBuffer(xmlHeader);
|
|
|
@ -70,9 +75,9 @@ Future<void> generateXmlFromArb({
|
|
|
|
|
|
|
|
|
|
|
|
final resourceId = key.substring(1);
|
|
|
|
final resourceId = key.substring(1);
|
|
|
|
final name = _escapeXml(resourceId);
|
|
|
|
final name = _escapeXml(resourceId);
|
|
|
|
final Map<String, dynamic> metaInfo = bundle[key];
|
|
|
|
final metaInfo = bundle[key] as Map<String, dynamic>;
|
|
|
|
assert(metaInfo != null && metaInfo['description'] != null);
|
|
|
|
assert(metaInfo != null && metaInfo['description'] != null);
|
|
|
|
var description = _escapeXml(metaInfo['description']);
|
|
|
|
var description = _escapeXml(metaInfo['description'] as String);
|
|
|
|
|
|
|
|
|
|
|
|
if (metaInfo.containsKey('plural')) {
|
|
|
|
if (metaInfo.containsKey('plural')) {
|
|
|
|
// Generate a plurals resource element formatted like this:
|
|
|
|
// Generate a plurals resource element formatted like this:
|
|
|
@ -110,8 +115,8 @@ Future<void> generateXmlFromArb({
|
|
|
|
// description's 'parameters' value, are replaced with printf positional
|
|
|
|
// description's 'parameters' value, are replaced with printf positional
|
|
|
|
// string arguments, like "%1$s".
|
|
|
|
// string arguments, like "%1$s".
|
|
|
|
var translation = translationFor(resourceId);
|
|
|
|
var translation = translationFor(resourceId);
|
|
|
|
assert(metaInfo['parameters'].trim().isNotEmpty);
|
|
|
|
assert((metaInfo['parameters'] as String).trim().isNotEmpty);
|
|
|
|
final parameters = metaInfo['parameters']
|
|
|
|
final parameters = (metaInfo['parameters'] as String)
|
|
|
|
.split(',')
|
|
|
|
.split(',')
|
|
|
|
.map<String>((s) => s.trim())
|
|
|
|
.map<String>((s) => s.trim())
|
|
|
|
.toList();
|
|
|
|
.toList();
|
|
|
@ -139,6 +144,5 @@ Future<void> generateXmlFromArb({
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
xml.writeln('</resources>');
|
|
|
|
xml.writeln('</resources>');
|
|
|
|
|
|
|
|
outputXml.write(xml.toString());
|
|
|
|
await outputXml.writeAsString(xml.toString());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|