public void TestParsing() { using (var stream = File.OpenRead(Path.Combine(LocalesDir, Path.Combine("ru_RU", Path.Combine("LC_MESSAGES", "Test.mo"))))) { var parser = new MoFileParser(); parser.Parse(stream); this._TestLoadedTranslation(parser.Translations); } }
public void TestManualEncoding() { using (var stream = File.OpenRead(Path.Combine(LocalesDir, Path.Combine("ru_RU", Path.Combine("LC_MESSAGES", "Test_KOI8-R.mo"))))) { var parser = new MoFileParser(Encoding.GetEncoding("KOI8-R"), false); var parsedFile = parser.Parse(stream); this._TestLoadedTranslation(parsedFile.Translations); } }
/// <summary> /// Initializes a new instance of the <see cref="MoLoader"/> class which will try to load a MO file /// from the specified stream. /// </summary> /// <param name="moStream"></param> /// <param name="pluralRuleGenerator"></param> /// <param name="parser"></param> public MoLoader(Stream moStream, IPluralRuleGenerator pluralRuleGenerator, MoFileParser parser) { if (moStream == null) throw new ArgumentNullException("moStream"); if (pluralRuleGenerator == null) throw new ArgumentNullException("pluralRuleGenerator"); if (parser == null) throw new ArgumentNullException("parser"); this._MoStream = moStream; this.PluralRuleGenerator = pluralRuleGenerator; this.Parser = parser; }
/// <summary> /// Initializes a new instance of the <see cref="MoLoader"/> class which will try to load a MO file /// from the specified stream. /// </summary> /// <param name="moStream"></param> /// <param name="pluralRuleGenerator"></param> /// <param name="parser"></param> public MoLoader(Stream moStream, IPluralRuleGenerator pluralRuleGenerator, MoFileParser parser) { if (moStream == null) { throw new ArgumentNullException("moStream"); } if (pluralRuleGenerator == null) { throw new ArgumentNullException("pluralRuleGenerator"); } if (parser == null) { throw new ArgumentNullException("parser"); } this._MoStream = moStream; this.PluralRuleGenerator = pluralRuleGenerator; this.Parser = parser; }
/// <summary> /// Initializes a new instance of the <see cref="MoLoader"/> class which will try to load a MO file /// from the specified path. /// </summary> /// <param name="filePath"></param> /// <param name="pluralRuleGenerator"></param> /// <param name="parser"></param> public MoLoader(string filePath, IPluralRuleGenerator pluralRuleGenerator, MoFileParser parser) { if (filePath == null) { throw new ArgumentNullException("filePath"); } if (pluralRuleGenerator == null) { throw new ArgumentNullException("pluralRuleGenerator"); } if (parser == null) { throw new ArgumentNullException("parser"); } this._FilePath = filePath; this.PluralRuleGenerator = pluralRuleGenerator; this.Parser = parser; }
/// <summary> /// Initializes a new instance of the <see cref="MoLoader"/> class which will try to load a MO file /// that will be located in the localeDir using the domain name and catalog's culture info. /// </summary> /// <param name="domain"></param> /// <param name="localeDir"></param> /// <param name="pluralRuleGenerator"></param> /// <param name="parser"></param> public MoLoader(string domain, string localeDir, IPluralRuleGenerator pluralRuleGenerator, MoFileParser parser) { if (domain == null) { throw new ArgumentNullException("domain"); } if (localeDir == null) { throw new ArgumentNullException("localeDir"); } if (pluralRuleGenerator == null) { throw new ArgumentNullException("pluralRuleGenerator"); } if (parser == null) { throw new ArgumentNullException("parser"); } this._Domain = domain; this._LocaleDir = localeDir; this.PluralRuleGenerator = pluralRuleGenerator; this.Parser = parser; }
/// <summary> /// Initializes a new instance of the <see cref="MoLoader"/> class which will try to load a MO file /// from the specified path. /// <see cref="AstPluralRuleGenerator"/> will be used to generate a plural form rule. /// </summary> /// <param name="filePath"></param> /// <param name="parser"></param> public MoAstPluralLoader(string filePath, MoFileParser parser) : base(filePath, new AstPluralRuleGenerator(), parser) { }
/// <summary> /// Load translations from given MO file stream using given encoding. /// </summary> /// <remarks> /// By default, parser will try to detect file encoding automatically with fallback to UTF-8 encoding. /// If you specify any encoding in this method, auto-detect will be turned off and given encoding will be used instead. /// </remarks> /// <param name="moStream">Stream that contain binary data in the MO file format</param> /// <param name="encoding">File encoding (auto detect by default)</param> public void Load(Stream moStream, Encoding encoding = null) { var parser = new MoFileParser(); if (encoding != null) { parser.DetectEncoding = false; parser.Encoding = encoding; } parser.Parse(moStream); this.Translations = parser.Translations; }
/// <summary> /// Initializes a new instance of the <see cref="MoLoader"/> class which will try to load a MO file /// from the specified path. /// </summary> /// <param name="filePath"></param> /// <param name="parser"></param> public MoLoader(string filePath, MoFileParser parser) : this(filePath, new DefaultPluralRuleGenerator(), parser) { }
/// <summary> /// Initializes a new instance of the <see cref="MoLoader"/> class which will try to load a MO file /// from the specified stream. /// </summary> /// <param name="moStream"></param> /// <param name="parser"></param> public MoLoader(Stream moStream, MoFileParser parser) : this(moStream, new DefaultPluralRuleGenerator(), parser) { }
/// <summary> /// Initializes a new instance of the <see cref="MoLoader"/> class which will try to load a MO file /// from the specified path. /// </summary> /// <param name="filePath"></param> /// <param name="pluralRuleGenerator"></param> /// <param name="parser"></param> public MoLoader(string filePath, IPluralRuleGenerator pluralRuleGenerator, MoFileParser parser) { if (filePath == null) throw new ArgumentNullException("filePath"); if (pluralRuleGenerator == null) throw new ArgumentNullException("pluralRuleGenerator"); if (parser == null) throw new ArgumentNullException("parser"); this._FilePath = filePath; this.PluralRuleGenerator = pluralRuleGenerator; this.Parser = parser; }
/// <summary> /// Initializes a new instance of the <see cref="MoLoader"/> class which will try to load a MO file /// that will be located in the localeDir using the domain name and catalog's culture info. /// </summary> /// <param name="domain"></param> /// <param name="localeDir"></param> /// <param name="parser"></param> public MoLoader(string domain, string localeDir, MoFileParser parser) : this(domain, localeDir, new DefaultPluralRuleGenerator(), parser) { }
/// <summary> /// Initializes a new instance of the <see cref="MoLoader"/> class which will try to load a MO file /// from the specified path. /// <see cref="CompiledPluralRuleGenerator"/> will be used to generate a plural form rule. /// </summary> /// <param name="filePath"></param> /// <param name="parser"></param> public MoCompilingPluralLoader(string filePath, MoFileParser parser) : base(filePath, new CompiledPluralRuleGenerator(), parser) { }
/// <summary> /// Initializes a new instance of the <see cref="MoAstPluralLoader"/> class which will try to load a MO file /// that will be located in the localeDir using the domain name and catalog's culture info. /// <see cref="AstPluralRuleGenerator"/> will be used to generate a plural form rule. /// </summary> /// <param name="domain"></param> /// <param name="localeDir"></param> /// <param name="parser"></param> public MoAstPluralLoader(string domain, string localeDir, MoFileParser parser) : base(domain, localeDir, new AstPluralRuleGenerator(), parser) { }
/// <summary> /// Initializes a new instance of the <see cref="MoLoader"/> class which will try to load a MO file /// from the specified stream. /// <see cref="AstPluralRuleGenerator"/> will be used to generate a plural form rule. /// </summary> /// <param name="moStream"></param> /// <param name="parser"></param> public MoAstPluralLoader(Stream moStream, MoFileParser parser) : base(moStream, new AstPluralRuleGenerator(), parser) { }
/// <summary> /// Initializes a new instance of the <see cref="MoLoader"/> class which will try to load a MO file /// that will be located in the localeDir using the domain name and catalog's culture info. /// <see cref="CompiledPluralRuleGenerator"/> will be used to generate a plural form rule. /// </summary> /// <param name="domain"></param> /// <param name="localeDir"></param> /// <param name="parser"></param> public MoCompilingPluralLoader(string domain, string localeDir, MoFileParser parser) : base(domain, localeDir, new CompiledPluralRuleGenerator(), parser) { }
/// <summary> /// Initializes a new instance of the <see cref="MoLoader"/> class which will try to load a MO file /// from the specified stream. /// <see cref="CompiledPluralRuleGenerator"/> will be used to generate a plural form rule. /// </summary> /// <param name="moStream"></param> /// <param name="parser"></param> public MoCompilingPluralLoader(Stream moStream, MoFileParser parser) : base(moStream, new CompiledPluralRuleGenerator(), parser) { }
/// <summary> /// Initializes a new instance of the <see cref="MoLoader"/> class which will try to load a MO file /// that will be located in the localeDir using the domain name and catalog's culture info. /// </summary> /// <param name="domain"></param> /// <param name="localeDir"></param> /// <param name="pluralRuleGenerator"></param> /// <param name="parser"></param> public MoLoader(string domain, string localeDir, IPluralRuleGenerator pluralRuleGenerator, MoFileParser parser) { if (domain == null) throw new ArgumentNullException("domain"); if (localeDir == null) throw new ArgumentNullException("localeDir"); if (pluralRuleGenerator == null) throw new ArgumentNullException("pluralRuleGenerator"); if (parser == null) throw new ArgumentNullException("parser"); this._Domain = domain; this._LocaleDir = localeDir; this.PluralRuleGenerator = pluralRuleGenerator; this.Parser = parser; }