internal GettextTranslationContext(LanguageTranslation languageTranslation)
 {
     if (languageTranslation == null) throw new ArgumentNullException("languageTranslation");
     this.languageTranslation = languageTranslation;
 }
        private static LanguageTranslation LoadCatalog(FileInfo f, LocaleFileOrganizationEnum fileOrganization)
        {
            if (f == null) throw new ArgumentNullException("f");
            if (!f.Exists) throw new GettextException("File " + f.FullName + " doesn't exist anymore!");

            string langId = null;
            if (fileOrganization == LocaleFileOrganizationEnum.FilePerLocale)
            {
                langId = f.Name.Replace(".po", "").Trim();
            } else
            {
                if (f.Directory != null) langId = f.Directory.Name.Trim();
            }

            if (langId == null) throw new GettextException("Language id for file " + f.FullName + " can't be determined.");

            using (var fs = f.OpenRead())
            {
                var catalog = GettextCatalog.ParseFromStream(fs);

                CultureInfo cultureInfo;
                try
                {
                    cultureInfo = CultureInfo.GetCultureInfo(langId);
                }
                catch (Exception)
                {
                    cultureInfo = CultureInfo.InvariantCulture;
                }

                var lt = new LanguageTranslation(langId, new Gettext(catalog), cultureInfo);

                return lt;
            }
        }