Permalink
Browse files

PoGenerator: add PotMode; when set, msgstrs will be empty

  • Loading branch information...
1 parent 9e44b51 commit ee6fb5c454d97161a3e98bf43b521ca77b6aec37 @abock abock committed Apr 28, 2012
Showing with 10 additions and 2 deletions.
  1. +4 −2 Vernacular.Generators/PoGenerator.cs
  2. +6 −0 Vernacular.Tool/Entry.cs
@@ -34,6 +34,8 @@ namespace Vernacular.Generators
{
public sealed class PoGenerator : Generator
{
+ public bool PotMode { get; set; }
+
private static string Escape (string value)
{
return String.IsNullOrWhiteSpace (value) ? value : value.Escape ();
@@ -154,10 +156,10 @@ protected override void Generate ()
}
if (translated.Length == 1) {
- WriteString ("msgstr", translated [0]);
+ WriteString ("msgstr", PotMode ? String.Empty : translated [0]);
} else {
for (int i = 0; i < translated.Length; i++) {
- WriteString (String.Format ("msgstr[{0}]", i), translated [i]);
+ WriteString (String.Format ("msgstr[{0}]", i), PotMode ? String.Empty : translated [i]);
}
}
@@ -50,6 +50,7 @@ public static void Main (string [] args)
string android_output_strings_xml = null;
string analyer_config_path = null;
LocalizationMetadata metadata = null;
+ bool generate_pot = false;
bool analyze = false;
bool log = false;
bool verbose = false;
@@ -73,6 +74,7 @@ public static void Main (string [] args)
"for preserving hand-maintained string resources", v => android_input_strings_xml = v },
{ "android-output-strings-xml=", "Output file of localized Android Strings.xml " +
"for preserving hand-maintained string resources", v => android_output_strings_xml = v },
+ { "pot", v => generate_pot = v != null },
{ "l|log", "Display logging", v => log = v != null },
{ "m|meta=", "Add localization metadata (key=value)", v => {
var parts = v.Split (new [] { '=' }, 2);
@@ -112,6 +114,10 @@ public static void Main (string [] args)
throw new OptionException ("invalid generator", "generator");
}
+ if (generator is PoGenerator && generate_pot) {
+ ((PoGenerator)generator).PotMode = true;
+ }
+
if (reduce_master_path != null && reduce_retain_path == null) {
throw new OptionException ("reduce-retain must be specified if reduce-master is", "reduce-retain");
} else if (reduce_master_path == null && reduce_retain_path != null) {

0 comments on commit ee6fb5c

Please sign in to comment.