Skip to content

Extractor Limitations

perpetualKid edited this page Feb 24, 2021 · 2 revisions

General string extraction

Only literal strings are supported in GetString* calls, no variables, function calls or expressions

    string testString = "stringA";
    //Not supported
    string notSupported = catalog.GetString(testString);

    //Supported
    string supported = catalog.GetString("stringA");

Expressions (function calls) are not supported in GetString* calls

    StringBuilder builder = new StringBuilder("StringA");
    //Not supported
    string test1 = catalog.GetString(stringBuilder.ToString());
    //Not supported
    string test2 = catalog.GetString(callingAMethodWhichReturnsString());

Simple Concatenation Expressions ('+') (function calls) are supported in GetString* calls

    //Supported
    string supported = catalog.GetString("stringA" + "stringB"); // This would extract "stringAstringB" as a single string
    //Not Supported
    string notSupported = catalog.GetString("stringA" + 0.ToString() + "stringB"); // This would only extract "stringAstringB"

Conditional Expressions need to be written as separate GetString* calls

    //Not Supported
    string notSupported = catalog.GetString(boolValue ? "stringA" : "stringB");
    //Supported
    string Supported = boolValue ? catalog.GetString("stringA") : catalog.GetString("stringB");

Windows Forms Control Properties

Conditional Expressions

Conditional Expressions (C# ?:) are supported as part of WinForms.Control property assignment for .Text, .HeaderText or .ToolTipText assignment

    //Supported when this is called before Localizer.Localize
    someControl.Text = boolValue ? "stringA" : "stringB";
    ...
    Localizer.Localize(form, catalog);

Only Control properties with Name Text, HeaderText or ToolTipText are supported

    //Supported
    someControl.Text = "stringA"; // this is typically in the Form.Designer.cs 

    //Not Supported neither from Extractor or Localizer
    someControl.AnotherTextProperty = "stringA";

    //Use the GetString* functionality instead
    //Supported both from Extractor and Localizer
    someControl.AnotherTextProperty = catalog.GetString("stringA"); // Put this in Form.Designer.cs or Form.cs but avoid overwriting autogenerated form designer code