コード例 #1
0
        public Dictionary<string, string> GetTranslations(LanguageCollection languageCollection, string value)
        {
            driver = new FirefoxDriver();
            baseURL = "http://www.nicetranslator.com/";

            driver.Navigate().GoToUrl(baseURL + "/");
            driver.FindElement(By.Id("addTranButn")).Click();

            Thread.Sleep(1000);
            foreach(var language in languageCollection.Languages)
                driver.FindElement(By.LinkText(language.Value)).Click();

            driver.FindElement(By.Id("addTranButn")).Click();
            driver.FindElement(By.Id("itxt")).Clear();
            driver.FindElement(By.Id("itxt")).SendKeys(value);

            Thread.Sleep(1000);

            foreach (var language in languageCollection.Languages)
            {
                var parent = driver.FindElement((By.Id("tx" + language.Key)));
                var child = parent.FindElement(By.ClassName("txtxt"));
                _translations.Add(language.Key, child.Text);
            }
            return _translations;
        }
コード例 #2
0
ファイル: Locale.cs プロジェクト: alexbikfalvi/DotNetApi
 /// <summary>
 /// Creates a locale instance for the specified culture.
 /// </summary>
 /// <param name="culture">The culture.</param>
 /// <param name="languages">An enumeration of languages.</param>
 /// <param name="scripts">An enumeration of scripts.</param>
 /// <param name="territories">An enumeration of territories.</param>
 public Locale(CultureId culture, IEnumerable<Language> languages, IEnumerable<Script> scripts, IEnumerable<Territory> territories)
 {
     this.languages = new LanguageCollection(culture, languages);
     this.scripts = new ScriptCollection(culture, scripts);
     this.territories = new TerritoryCollection(culture, territories);
     this.Culture = culture;
 }
コード例 #3
0
ファイル: Locale.cs プロジェクト: alexbikfalvi/DotNetApi
 /// <summary>
 /// Creates a locale instance for the specified culture.
 /// </summary>
 /// <param name="culture">The culture.</param>
 public Locale(CultureId culture)
 {
     this.languages = new LanguageCollection(culture);
     this.scripts = new ScriptCollection(culture);
     this.territories = new TerritoryCollection(culture);
     this.Culture = culture;
 }
コード例 #4
0
ファイル: Language.cs プロジェクト: black78/ToolsCatalog
		/// <summary>
		/// Initializes a new instance of the <see cref="Language"/> class.
		/// </summary>
		/// <param name="languageDto">
		/// The data transfer object with language data.
		/// </param>
		/// <param name="displayNameProvider">
		/// A language name translation provider.
		/// </param>
		/// <param name="flat">Indicates that no children should be created.</param>
		internal Language(
			LanguageDto languageDto,
			LanguageDisplayNameProvider displayNameProvider,
			bool flat)
		{
			_displayNameProvider = displayNameProvider;

			Lcid = languageDto.Lcid;
			SystemLcid = languageDto.SystemLcid;
			IsNeutral = languageDto.IsNeutral;
			IsToolsCatalogSpecific = languageDto.IsToolsCatalogSpecific;
			IsSimplified = languageDto.IsSimplified;
			IsUncorrected = languageDto.IsUncorrected;
			Name = languageDto.Name;
			DefaultCodePage = languageDto.DefaultCodePage;
			Abbreviation = languageDto.Abbreviation;

			var children = new List<Language>();

			if (!flat)
			{
				foreach (LanguageDto child in languageDto.Children)
				{
					var childLanguage = new Language(child, displayNameProvider, false) { Parent = this };
					children.Add(childLanguage);
				}
			}

			Children = new LanguageCollection(children);
		}
コード例 #5
0
        public GbrFilesInfo(LanguageCollection languageCollection)
        {
            LanguageCollection = languageCollection;
            _filesInfo = new List<FileInfo>();

            foreach(var language in languageCollection.Languages)
                _filesInfo.Add(new FileInfo(FOLDER_ROOT +
                    FILE_NAME_START + language.Key + FILE_NAME_EXT));
        }
コード例 #6
0
        public void GetLanguagesReturnsValidLanguageCollection()
        {
            var en = Language.Parse("en");
            var da = Language.Parse("da");
            var expected = new LanguageCollection { en, da };
            var sut = new DbLanguages(en, da);

            var actual = sut.GetLanguages();

            actual.ShouldAllBeEquivalentTo(expected);
        }
コード例 #7
0
        void BOkClick(object sender, EventArgs e)
        {
            LanguageCollection checkedFromLanguages = new LanguageCollection();
            LanguageCollection checkedToLanguages = new LanguageCollection();

            foreach(LanguageDataContainer ldc in lbFrom.CheckedItems)
            {
                if(ldc.Language != Language.Any)
                    checkedFromLanguages.Add(ldc.Language);
            }

            foreach(LanguageDataContainer ldc in lbTo.CheckedItems)
            {
                if(ldc.Language != Language.Any)
                    checkedToLanguages.Add(ldc.Language);
            }

            if(checkedFromLanguages.Count == 0)
            {
                MessageBox.Show(FindForm(),
                    TranslateString("Please select at least one source language"),
                        Constants.AppName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                DialogResult = DialogResult.None;
                return;
            }

            if(checkedToLanguages.Count == 0)
            {
                MessageBox.Show(FindForm(),
                    TranslateString("Please select at least one target language"),
                        Constants.AppName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                DialogResult = DialogResult.None;
                return;
            }

            profile.DisabledSourceLanguages.Clear();
            foreach(LanguageDataContainer ldc in lbFrom.Items)
            {
                if(ldc.Language != Language.Any && !checkedFromLanguages.Contains(ldc.Language))
                {
                    profile.DisabledSourceLanguages.Add(ldc.Language);
                }
            }

            profile.DisabledTargetLanguages.Clear();
            foreach(LanguageDataContainer ldc in lbTo.Items)
            {
                if(ldc.Language != Language.Any && !checkedToLanguages.Contains(ldc.Language))
                    profile.DisabledTargetLanguages.Add(ldc.Language);
            }
        }
コード例 #8
0
        private static LanguageCollection DBMapping(DBLanguageCollection dbCollection)
        {
            if (dbCollection == null)
                return null;

            LanguageCollection collection = new LanguageCollection();
            foreach (DBLanguage dbItem in dbCollection)
            {
                Language item = DBMapping(dbItem);
                collection.Add(item);
            }

            return collection;
        }
コード例 #9
0
    void OnEnable()
    {
        dialogCollection   = Resources.Load("Dialogs") as DialogCollection;
        languageCollection = Resources.Load("Localization") as LanguageCollection;

        // If one hasn't been created yet, build one.
        if (dialogCollection == null)
        {
            dialogCollection = DialogCollectionBuilder.Build();
        }

        // If one hasn't been created yet, build one.
        if (languageCollection == null)
        {
            languageCollection = LanguageCollectionBuilder.Build();
        }
    }
コード例 #10
0
        public IEnumerable <ICountry> GetCountries(SiteContext context)
        {
            var countries = new List <ICountry>();
            LanguageCollection languages = context.Database.GetLanguages();

            foreach (var language in languages)
            {
                Country country = new Country
                {
                    Name     = language.CultureInfo.DisplayName,
                    ImageUrl = "/~/icon/" + language.GetIcon(context.Database),
                    Url      = "http://" + GetSite(language.Name).HostName
                };
                countries.Add(country);
            }
            return(countries);
        }
コード例 #11
0
        static GoogleTranslator()
        {
            languages = new LanguageCollection();
            languages.Add(Language.Autodetect);
            languages.Add(Language.Arabic);
            languages.Add(Language.Bulgarian);
            languages.Add(Language.Catalan);
            languages.Add(Language.Chinese);
            languages.Add(Language.Chinese_CN);
            languages.Add(Language.Chinese_TW);
            languages.Add(Language.Croatian);
            languages.Add(Language.Czech);
            languages.Add(Language.Danish);
            languages.Add(Language.Dutch);
            languages.Add(Language.English);
            languages.Add(Language.Filipino);
            languages.Add(Language.Finnish);
            languages.Add(Language.French);
            languages.Add(Language.German);
            languages.Add(Language.Greek);
            languages.Add(Language.Hebrew);
            languages.Add(Language.Hindi);
            languages.Add(Language.Indonesian);
            languages.Add(Language.Italian);
            languages.Add(Language.Japanese);
            languages.Add(Language.Korean);
            languages.Add(Language.Latvian);
            languages.Add(Language.Lithuanian);
            languages.Add(Language.Norwegian);
            languages.Add(Language.Polish);
            languages.Add(Language.Portuguese);
            languages.Add(Language.Romanian);
            languages.Add(Language.Russian);
            languages.Add(Language.Serbian);
            languages.Add(Language.Slovak);
            languages.Add(Language.Slovenian);
            languages.Add(Language.Spanish);
            languages.Add(Language.Swedish);
            languages.Add(Language.Ukrainian);
            languages.Add(Language.Vietnamese);

            char[] delimiterChars = { ',', '.', ';', '\n', '!', '?'};

            delimiterCharsList = new List<char>(delimiterChars);
            delimiterCharsList.Sort();
        }
コード例 #12
0
        public ActionResult ContentExport(string id)
        {
            var model = new ExportModel();

            try
            {
                if (!string.IsNullOrEmpty(id))
                {
                    model.ID = id;
                    LanguageCollection    languages = LanguageManager.GetLanguages(_masterDb);
                    List <SelectListItem> list      = new List <SelectListItem>();
                    foreach (Language item in (Collection <Language>)(object) languages)
                    {
                        SelectListItem val = new SelectListItem
                        {
                            Text  = item.CultureInfo.DisplayName,
                            Value = item.CultureInfo.Name
                        };
                        list.Add(val);
                    }
                    if (list?.Any() ?? false)
                    {
                        model.AvailableLanguages = list;
                    }
                    List <SelectListItem> templates = new List <SelectListItem>();
                    foreach (var item in ScHelpers.GetTemplates())
                    {
                        SelectListItem val = new SelectListItem
                        {
                            Text  = item.DisplayName.ToString(),
                            Value = item.ID.ToString()
                        };
                        templates.Add(val);
                    }
                    if (templates?.Any() ?? false)
                    {
                        model.Templates = templates;
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error("Export", ex, (object)model);
            }
            return(View("~/Views/ContentAuthoring/ContentExport.cshtml", model));
        }
コード例 #13
0
 /// <summary>
 /// Updates the context result with the given Language Collection
 /// </summary>
 /// <param name="result"></param>
 /// <param name="context"></param>
 private static void UpdateContext(LanguageCollection result, CallContext context)
 {
     if (result != null)
     {
         LanguageCollection currentResult = context.CurrentResult as LanguageCollection;
         if (currentResult != null)
         {
             Language[] languageArray = (Language[])MainUtil.AddArrays(currentResult.ToArray(), result.ToArray(), typeof(Language));
             result = new LanguageCollection();
             for (int i = 0; i < languageArray.Length; i++)
             {
                 result.Add(languageArray[i]);
             }
         }
         context.CurrentResult = result;
     }
     context.SetNextIndex(context.Index + 1);
 }
コード例 #14
0
        /// <summary>
        /// Fill the entity properties using a source.
        /// </summary>
        ///
        /// <param name="source">
        /// Source.
        public override void Map(EntityBase source)
        {
            if (source == null)
            {
                ThrowException.ThrowArgumentNullException("source");
            }

            if (!(source is Translation))
            {
                ThrowException.ThrowArgumentException("The 'source' argument is not a 'Translation' instance");
            }

            this.Key   = ((Translation)source).Key;
            this.Value = new LanguageCollection(((Translation)source).Value);

            this.Id    = source.Id;
            this.State = source.State;
        }
コード例 #15
0
        private void FillDropDowns()
        {
            this.ddlLanguage.Items.Clear();
            ListItem ddlLanguageItem = new ListItem(GetLocaleResourceString("Admin.LocaleStringResources.SelectLanguage"), "0");

            this.ddlLanguage.Items.Add(ddlLanguageItem);
            LanguageCollection languageCollection = LanguageManager.GetAllLanguages();

            foreach (Language language in languageCollection)
            {
                ListItem ddlLanguageItem2 = new ListItem(language.Name, language.LanguageID.ToString());
                this.ddlLanguage.Items.Add(ddlLanguageItem2);
                if (this.LanguageID == language.LanguageID)
                {
                    ddlLanguageItem2.Selected = true;
                }
            }
        }
コード例 #16
0
        public static LanguageCollection GetAllItem(int CompanyID)
        {
            LanguageCollection collection = new LanguageCollection();

            var sqlParams = new SqlParameter[]
            {
                new SqlParameter("@CompanyID", CompanyID),
            };

            using (var reader = SqlHelper.ExecuteReader("tblLanguage_GetAll", sqlParams))
            {
                while (reader.Read())
                {
                    Language obj = new Language();
                    obj = GetItemFromReader(reader);
                    collection.Add(obj);
                }
            }
            return(collection);
        }
コード例 #17
0
        /// <summary>
        /// Gets all languages
        /// </summary>
        /// <param name="showHidden">A value indicating whether to show hidden records</param>
        /// <returns>Language collection</returns>
        public static LanguageCollection GetAllLanguages(bool showHidden)
        {
            string key  = string.Format(LANGUAGES_ALL_KEY, showHidden);
            object obj2 = NopCache.Get(key);

            if (LanguageManager.CacheEnabled && (obj2 != null))
            {
                return((LanguageCollection)obj2);
            }

            DBLanguageCollection dbCollection = DBProviderManager <DBLanguageProvider> .Provider.GetAllLanguages(showHidden);

            LanguageCollection languageCollection = DBMapping(dbCollection);

            if (LanguageManager.CacheEnabled)
            {
                NopCache.Max(key, languageCollection);
            }
            return(languageCollection);
        }
コード例 #18
0
        public CodeStash3ViewModel()
        {
            try
            {
                BLL.ISnippetRepository snippetRepository;
                BLL.SnippetCollection  bllSnippetCollection;


                snippetRepository    = SnippetRepositoryFactory.GetRepository(Settings.Default.repoType);
                bllSnippetCollection = new BLL.SnippetCollection(snippetRepository);

                _snippetsOriginal        = new SnippetCollection(bllSnippetCollection).ToList();
                _dirtySnippetsCollection = new ObservableCollection <Snippet>(_snippetsOriginal);
                _languages = new LanguageCollection(new BLL.LanguageCollection(bllSnippetCollection).GenerateLanguageList());
            }
            catch (Exception e)
            {
                MessageBox.Show("An error has occured");
            }
        }
コード例 #19
0
        /// <summary>
        /// Loads main data when the VnInfo view shows up
        /// </summary>
        protected override void OnViewLoaded()
        {
            LanguageCollection.Clear();
            TagCollection.Clear();
            VnRelations.Clear();

            VndbLink = new Tuple <string, Visibility>(string.Empty, Visibility.Visible);
            WikiLink = new Tuple <string, Visibility>(string.Empty, Visibility.Collapsed);
            LoadMainData();
            LoadUserData();
            LoadRelations();
            LoadLinks();

            TagCollection.AddRange(VndbTagTraitHelper.GetTags(VndbContentViewModel.VnId));
            SummaryHeaderVisibility  = DescriptionInLine.Length < 1 ? Visibility.Collapsed : Visibility.Visible;
            TagHeaderVisibility      = TagCollection.Count < 1 ? Visibility.Collapsed : Visibility.Visible;
            RelationHeaderVisibility = VnRelations.Count < 1 ? Visibility.Collapsed : Visibility.Visible;
            RelationsDataVisibility  = VnRelations.Count < 1 ? Visibility.Collapsed : Visibility.Visible;
            IsStartButtonVisible     = Visibility.Visible;
        }
コード例 #20
0
        public static LanguageCollection GetbyUser(string CreatedUser, int CompanyID)
        {
            LanguageCollection collection = new LanguageCollection();
            Language           obj;
            var sqlParams = new SqlParameter[]
            {
                new SqlParameter("@CreatedUser", CreatedUser),
                new SqlParameter("@CompanyID", CompanyID),
            };

            using (var reader = SqlHelper.ExecuteReader("tblLanguage_GetAll_byUser", sqlParams))
            {
                while (reader.Read())
                {
                    obj = GetItemFromReader(reader);
                    collection.Add(obj);
                }
            }
            return(collection);
        }
コード例 #21
0
ファイル: Language.ascx.cs プロジェクト: NCIOCPL/pubslocator
        protected void gvResult_UpdateCommand(object source, DataGridCommandEventArgs e)
        {
            LanguageCollection dt = ((LanguageCollection)this.gvResult.DataSource);

            PubEntAdmin.BLL.Language l_conf = dt[e.Item.ItemIndex];
            int    Lngid   = l_conf.LngID;
            string Lngname = ((TextBox)e.Item.Cells[1].Controls[1]).Text;

            int    Active  = 0;
            string sActive = ((Label)e.Item.Cells[2].Controls[1]).Text;

            if (sActive == "Active")
            {
                Active = 1;
            }
            else
            {
                Active = 0;
            }

            Boolean valid    = false;
            Boolean validnum = false;
            Boolean validlen = false;

            if (Lngname.Length != 0)
            {
                valid    = PubEntAdminManager.OtherVal(Lngname);
                validnum = PubEntAdminManager.SpecialVal2(Lngname);
                validlen = PubEntAdminManager.LenVal(Lngname, 50);
            }

            if ((valid == false) && (validnum == false) && (validlen == true))
            {
                LU_DAL.UpdateLanguageLU(Lngid, Lngname, Active);
                Response.Redirect("~/LookupMgmt.aspx?sub=language");
            }
            else
            {
                Response.Redirect("InvalidInput.aspx");
            }
        }
コード例 #22
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        data = (LanguageCollection)target;
        if (contentDownloading.Equals(string.Empty))
        {
            if (GUILayout.Button("Select All"))
            {
                SelectAllLanguage();
            }

            if (GUILayout.Button("Download Data Language"))
            {
                DownLoadFileLanguage();
            }
        }
        else
        {
            EditorGUILayout.HelpBox($"Download: {contentDownloading}", MessageType.None);
        }
    }
コード例 #23
0
        public void DeleteLanguage()
        {
            try
            {
                int languageID = LanguageCollection[SelectedIndex].ID;

                var forgeDatabase = Global.Instance.ForgeDatabase();

                LANGUAGE language = forgeDatabase.Languages.Single(x => x.ID == languageID);

                forgeDatabase.Languages.DeleteOnSubmit(language);
                forgeDatabase.SubmitChanges();

                LanguageCollection.RemoveAt(SelectedIndex);
                Global.Instance.LanguageCollection = new BindableCollection <LanguageCollection>(LanguageCollection);

                ClearLanguageInfo();
                SelectedIndex = -1;
            }
            catch { }
        }
コード例 #24
0
        //Load numbered versions in the dropdown for master and web items


        //private void PopuplateItemVersionsDropdowns()
        //{
        //    PopuplateItemVersionsDropdown(MasterVersionDropdown, GetMasterItem());
        //    PopuplateItemVersionsDropdown(WebVersionDropdown, GetWebItem());
        //}

        //private static void PopuplateItemVersionsDropdown(Combobox itemVersionsDropdown, Item itemVersions)
        //{
        //    foreach (var version in itemVersions.Versions.GetVersions())
        //    {
        //        itemVersionsDropdown.Controls.Add(
        //            new ListItem {
        //                ID = Sitecore.Web.UI.HtmlControls.Control.GetUniqueID("ListItem"),
        //                Header = version.Version.Number.ToString(),
        //                Value = version.Version.Number.ToString(),
        //                Selected = string.Equals(version.Name, itemVersions.Name)
        //            }
        //            );
        //    }
        //}
        #endregion

        private static void PopuplateLanguageDropdown(Combobox languageDropdown)
        {
            LanguageCollection languageVersions = ItemManager.GetContentLanguages(GetDatabase("master").GetItem(MainUtil.GetID(GetGetQueryStringProperty(IDKey, IDKey), ID.Null)));

            foreach (var language in languageVersions)
            {
                var itm = GetDatabase("master").GetItem(MainUtil.GetID(GetGetQueryStringProperty(IDKey, IDKey), ID.Null), language);
                if (itm.Versions.Count > 0)
                {
                    languageDropdown.Controls.Add
                    (
                        new Sitecore.Web.UI.HtmlControls.ListItem
                    {
                        ID       = Sitecore.Web.UI.HtmlControls.Control.GetUniqueID("ListItem"),
                        Header   = language.Title + " - " + language.Name, //To-do - remove obsolete reference
                        Value    = language.Name,
                        Selected = string.Equals(language.Name, Context.Language)
                    }
                    );
                }
            }
        }
コード例 #25
0
        public static LanguageCollection GetAll(int CompanyID)
        {
            LanguageCollection items = new LanguageCollection();
            string             key   = String.Format(SETTINGS_ALL_KEY, CompanyID);
            object             obj2  = HttpCache.Get(key);

            if ((obj2 != null))
            {
                return((LanguageCollection)obj2);
            }
            using (var client = WebApiHelper.myclient(HouseEndpoint, SystemConst.APIJosonReturnValue))
            {
                HttpResponseMessage response = client.GetAsync(string.Format(Resource + "?CompanyID={0}", CompanyID)).GetAwaiter().GetResult();

                if (response.IsSuccessStatusCode)
                {
                    items = response.Content.ReadAsAsync <LanguageCollection>().GetAwaiter().GetResult();
                }
            }
            HttpCache.Max(key, items);
            return(items);
        }
コード例 #26
0
 private void ClearVnData()
 {
     TreeVnCategories.Clear();
     LanguageCollection.Clear();
     OriginalLanguagesCollection.Clear();
     VnInfoRelation.Clear();
     VnInfoTagCollection.Clear();
     VnInfoAnimeCollection.Clear();
     PlatformCollection.Clear();
     VnMainModel.Name        = String.Empty;
     VnMainModel.Original    = String.Empty;
     VnMainModel.PlayTime    = String.Empty;
     VnMainModel.LastPlayed  = String.Empty;
     VnMainModel.Image       = null;
     VnMainModel.Aliases     = String.Empty;
     VnMainModel.Description = String.Empty;
     VnMainModel.Released    = String.Empty;
     VnMainModel.Length      = String.Empty;
     VnMainModel.VnIcon      = null;
     VnMainModel.Popularity  = 0;
     VnMainModel.Rating      = 0;
     VnMainModel.Links       = string.Empty;
 }
コード例 #27
0
    private void SaveDictionary(string fileName)
    {
        string json = JsonUtility.ToJson(LanguageCollection.DictionaryToCollection(ourLanguage.languageDictionary), true);

#if UNITY_EDITOR
        string path = "Assets/Resources/GameJSONData/" + fileName + "ItemInfo.json";
#endif
#if UNITY_STANDALONE
        // You cannot add a subfolder, at least it does not work for me
        path = "Assets/Resources/" + fileName + ".json";
#endif
        string str = json;
        using (FileStream fs = new FileStream(path, FileMode.Create))
        {
            using (StreamWriter writer = new StreamWriter(fs))
            {
                writer.Write(str);
            }
        }
#if UNITY_EDITOR
        UnityEditor.AssetDatabase.Refresh();
#endif
    }
コード例 #28
0
        /// <summary>
        /// Renders available publishing languages.
        /// </summary>
        private void BuildLanguages()
        {
            LanguageCollection languages = LanguageManager.GetLanguages(_database);

            if (languages == null)
            {
                Log.Warn("Scheduled Publish: No publish languages found", this);
                return;
            }

            foreach (var language in languages)
            {
                if (!CanWriteLanguage(language))
                {
                    continue;
                }

                string id = Control.GetUniqueID("lang_");

                HtmlGenericControl langInput = new HtmlGenericControl("input");
                langInput.ID = id;
                langInput.Attributes["type"]  = "checkbox";
                langInput.Attributes["value"] = language.Name;
                if (languages.Count == 1)
                {
                    langInput.Attributes["checked"] = "checked";
                }
                Languages.Controls.Add(langInput);

                HtmlGenericControl langLabel = new HtmlGenericControl("label");
                langLabel.Attributes["for"] = id;
                langLabel.InnerText         = language.CultureInfo.DisplayName;
                Languages.Controls.Add(langLabel);

                Languages.Controls.Add(new LiteralControl("<br/>"));
            }
        }
コード例 #29
0
        private void BindLanguages()
        {
            LanguageCollection languages = LanguageManager.GetAllLanguages(false);

            if (languages.Count > 1)
            {
                this.Visible = true;
                this.ddlLanguages.Items.Clear();
                Language customerLanguage = NopContext.Current.WorkingLanguage;
                foreach (Language language in languages)
                {
                    ListItem item = new ListItem(language.Name, language.LanguageID.ToString());
                    this.ddlLanguages.Items.Add(item);
                }
                if (customerLanguage != null)
                {
                    CommonHelper.SelectListItem(this.ddlLanguages, customerLanguage.LanguageID);
                }
            }
            else
            {
                this.Visible = false;
            }
        }
コード例 #30
0
        /// <summary>
        /// Gets all the languages available in the current database
        /// </summary>
        /// <returns></returns>
        protected virtual LanguageCollection LoadLanguages()
        {
            #region VARIABLES

            LanguageCollection      oLanguages;
            List <LanguageContract> oGenLanguages;
            ID       oLanguageOriginItemId;
            Language oLanguage;

            #endregion

            oLanguages = null;

            using (var oContentService = new GenContentServiceProxy())
            {
                oGenLanguages = oContentService.GetLanguages(this.CurrentDatabase);
            }

            if (oGenLanguages != null)
            {
                oLanguages = new LanguageCollection();
                foreach (LanguageContract sGenLanguage in oGenLanguages)
                {
                    if (!string.IsNullOrEmpty(sGenLanguage.OriginItemId) && !string.IsNullOrEmpty(sGenLanguage.Name) && !string.Equals(sGenLanguage.Name, "*") && ID.TryParse(sGenLanguage.OriginItemId, out oLanguageOriginItemId))
                    {
                        if (Language.TryParse(sGenLanguage.Name, out oLanguage) && !oLanguages.Contains(oLanguage))
                        {
                            oLanguage.Origin.ItemId = oLanguageOriginItemId;
                            oLanguages.Add(oLanguage);
                        }
                    }
                }
            }

            return(oLanguages);
        }
コード例 #31
0
        public DbLanguages(params Language[] languages)
        {
            Assert.ArgumentNotNull(languages, "languages");

            this.languages = new LanguageCollection(languages);
        }
コード例 #32
0
 public override LanguageCollection GetLanguages(CallContext context)
 {
     /* return an empty language collection otherwise two additional languages appear in the content editor */
     LanguageCollection collection = new LanguageCollection();
     return collection;
 }
コード例 #33
0
ファイル: PrefetchData.cs プロジェクト: dsolovay/SitecoreData
 public void InitializeFieldLists(LanguageCollection languages)
 {
     foreach (Language language in languages)
     {
         this.AddFieldList(language, Version.First);
     }
     this.AddFieldList(Language.Invariant, Version.First);
 }
コード例 #34
0
        void LoadLanguages()
        {
            LockUpdate(true);
            lbFrom.BeginUpdate();
            lbFrom.Items.Clear();
            lbTo.Items.Clear();

            LanguageCollection fromLangs = new LanguageCollection();
            int index;
            foreach(LanguagePair lp in languages)
            {
                index = fromLangs.BinarySearch(lp.From);
                if(index < 0)
                    fromLangs.Insert(~index, lp.From);
            }

            string val = "";

            if(fromLangs.Count > 1)
            {
                val = "+" + LangPack.TranslateLanguage(Language.Any);
                lbFrom.Items.Add(new LanguageDataContainer(Language.Any, val));
            }

            foreach(Language l in fromLangs)
            {
                val = LangPack.TranslateLanguage(l);
                if(l == Language.Autodetect)
                    val = "÷" + val;
                lbFrom.Items.Add(new LanguageDataContainer(l, val));
            }

            lbFrom.EndUpdate();

            if(lbFrom.Items.Count > 0 && !profileChanging)
                lbFrom.SelectedIndex = 0;
            LockUpdate(false);
        }
コード例 #35
0
        public LiveTranslator()
        {
            CharsLimit = 15000;
            WordsLimit = 500;
            Name = "_translator";

            AddSupportedSubject(SubjectConstants.Common);

            LanguageCollection tmp = new LanguageCollection();
            LanguageCollection languages = new LanguageCollection();
            foreach(KeyValuePair<Language, string> kvp in langToKey)
            {
                if(kvp.Key != Language.English_GB && kvp.Key != Language.English_US)
                {
                    tmp.Add(kvp.Key);
                    languages.Add(kvp.Key);
                }
            }

            foreach(Language from in languages)
            {
                foreach(Language to in tmp)
                {
                    if(from != to && to != Language.Autodetect)
                    {
                        if(from == Language.English)
                        {
                            AddSupportedTranslationFromEnglish(to);
                        }
                        else if(to == Language.English)
                        {
                            AddSupportedTranslationToEnglish(from);
                        }
                        else
                        {
                            AddSupportedTranslation(from, to);
                        }
                    }
                }
            }
        }
コード例 #36
0
        public DbLanguages(params Language[] languages)
        {
            Assert.ArgumentNotNull(languages, "languages");

            this.languages = new LanguageCollection(languages);
        }
コード例 #37
0
        public GoogleTranslator()
        {
            LanguageCollection tmp = new LanguageCollection(languages);

            foreach(Language from in languages)
            {
                foreach(Language to in tmp)
                {
                    if(from != to && to != Language.Autodetect)
                    {
                        if(from == Language.English)
                        {
                            AddSupportedTranslationFromEnglish(to);
                            if(to == Language.Filipino)
                                AddSupportedTranslationFromEnglish(Language.Tagalog);
                        }
                        else if(to == Language.English)
                        {
                            AddSupportedTranslationToEnglish(from);
                            if(from == Language.Filipino)
                                AddSupportedTranslationToEnglish(Language.Tagalog);
                        }
                        else
                        {
                            AddSupportedTranslation(from, to);
                            if(from == Language.Filipino)
                                AddSupportedTranslation(Language.Tagalog, to);
                            else if(to == Language.Filipino)
                                AddSupportedTranslation(from, Language.Tagalog);
                        }
                    }
                }
            }

            AddSupportedSubject(SubjectConstants.Common);
            CharsLimit = 2500;
        }
コード例 #38
0
        private void BindVnData()
        {
            IsMainBinding = true;

            try
            {
                Globals.StatusBar.ProgressText = "Loading Main Data";
                double ProgressIncrement = 11.11111111111111;
                Globals.StatusBar.ProgressPercentage = 0;
                Globals.StatusBar.IsWorkProcessing   = true;
                using (var context = new DatabaseContext())
                {
                    #region VnInfo
                    foreach (VnInfo vnInfo in context.VnInfo.Where(t => t.Title == (_selectedVn)))
                    {
                        Globals.VnId = vnInfo.VnId;


                        foreach (string language in GetLangauges(vnInfo.Languages))
                        {
                            LanguageCollection.Add(new LanguagesCollection
                            {
                                VnMainModel = new VnMainModel {
                                    Languages = new BitmapImage(new Uri(language))
                                }
                            });
                        }

                        foreach (string platform in GetPlatforms(vnInfo.Platforms))
                        {
                            PlatformCollection.Add(new PlatformCollection
                            {
                                VnMainModel = new VnMainModel {
                                    Platforms = new BitmapImage(new Uri(platform))
                                }
                            });
                        }

                        if (Globals.StatusBar.ProgressPercentage != null)
                        {
                            Globals.StatusBar.ProgressPercentage =
                                (double)Globals.StatusBar.ProgressPercentage + ProgressIncrement;
                        }

                        foreach (string language in GetLangauges(vnInfo.OriginalLanguage))
                        {
                            OriginalLanguagesCollection.Add(new OriginalLanguagesCollection
                            {
                                VnMainModel =
                                    new VnMainModel {
                                    OriginalLanguages = new BitmapImage(new Uri(language))
                                }
                            });
                        }
                        if (Globals.StatusBar.ProgressPercentage != null)
                        {
                            Globals.StatusBar.ProgressPercentage =
                                (double)Globals.StatusBar.ProgressPercentage + ProgressIncrement;
                        }

                        VnMainModel.Description = ConvertTextBBcode.ConvertText(vnInfo.Description);
                        if (Globals.StatusBar.ProgressPercentage != null)
                        {
                            Globals.StatusBar.ProgressPercentage =
                                (double)Globals.StatusBar.ProgressPercentage + ProgressIncrement;
                        }

                        BindCoverImage(Convert.ToBoolean(vnInfo.ImageNsfw));
                        if (Globals.StatusBar.ProgressPercentage != null)
                        {
                            Globals.StatusBar.ProgressPercentage =
                                (double)Globals.StatusBar.ProgressPercentage + ProgressIncrement;
                        }

                        VnMainModel.Name     = vnInfo.Title;
                        VnMainModel.Original = vnInfo.Original;
                        VnMainModel.Released = vnInfo.Released;
                        VnMainModel.Aliases  = vnInfo.Aliases;
                        switch (vnInfo.Length)
                        {
                        case "VeryShort":
                            VnMainModel.Length = "Very short";
                            break;

                        case "VeryLong":
                            VnMainModel.Length = "Very long";
                            break;

                        default:
                            VnMainModel.Length = vnInfo.Length;
                            break;
                        }
                        VnMainModel.Popularity = Math.Round(Convert.ToDouble(vnInfo.Popularity), 2);
                        VnMainModel.Rating     = Convert.ToInt32(vnInfo.Rating);
                        break;
                    }


                    #endregion

                    #region VnIcon
                    VnMainModel.VnIcon = LoadIcon();
                    if (Globals.StatusBar.ProgressPercentage != null)
                    {
                        Globals.StatusBar.ProgressPercentage =
                            (double)Globals.StatusBar.ProgressPercentage + ProgressIncrement;
                    }
                    #endregion

                    #region VnAnime

                    foreach (var anime in context.VnInfoAnime.Where(v => v.VnId == Globals.VnId))
                    {
                        VnInfoAnimeCollection.Add(
                            new VnInfoAnime
                        {
                            Title        = anime.TitleEng,
                            OriginalName = anime.TitleJpn,
                            Year         = anime.Year,
                            AnimeType    = anime.AnimeType,
                            AniDb        = $"anidb.net/a{anime.AniDbId}",
                            Ann          = $"animenewsnetwork.com/encyclopedia/anime.php?id={anime.AnnId}",
                            //TODO: AnimeNFo not added because of inconsistant url naming scheme
                        });
                    }
                    if (Globals.StatusBar.ProgressPercentage != null)
                    {
                        Globals.StatusBar.ProgressPercentage =
                            (double)Globals.StatusBar.ProgressPercentage + ProgressIncrement;
                    }

                    #endregion

                    #region VnTags

                    SetTags();

                    if (Globals.StatusBar.ProgressPercentage != null)
                    {
                        Globals.StatusBar.ProgressPercentage =
                            (double)Globals.StatusBar.ProgressPercentage + ProgressIncrement;
                    }

                    #endregion

                    #region VnLinks

                    foreach (VnInfoLinks links in context.VnInfoLinks.Where(v => v.VnId == Globals.VnId))
                    {
                        string wikipedia = String.Empty;
                        string encubed   = String.Empty;
                        string renai     = String.Empty;
                        if (!string.IsNullOrEmpty(links.Wikipedia))
                        {
                            wikipedia = $@"[url=https://en.wikipedia.org/wiki/{links.Wikipedia}]Wikipedia[/url]";
                        }
                        if (!string.IsNullOrEmpty(links.Encubed))
                        {
                            encubed = $@"[url=http://novelnews.net/tag/{links.Encubed}]Encubed[/url]";
                        }
                        if (!string.IsNullOrEmpty(links.Renai))
                        {
                            renai = $@"[url=https://renai.us/game/{links.Renai}]Renai[/url]";
                        }
                        List <string> combinedList = new List <string> {
                            wikipedia, encubed, renai
                        };

                        string combined = string.Join(", ", combinedList.Where(s => !string.IsNullOrEmpty(s)));
                        VnMainModel.Links = combined;
                    }


                    #endregion

                    #region VnRelations

                    foreach (VnInfoRelations relation in context.VnInfoRelations.Where(v => v.VnId == Globals.VnId))
                    {
                        VnInfoRelation.Add(
                            new VnInfoRelation
                        {
                            Title    = relation.Title,
                            Original = relation.Original,
                            Relation = relation.Relation,
                            Official = relation.Official
                        });
                    }
                    if (Globals.StatusBar.ProgressPercentage != null)
                    {
                        Globals.StatusBar.ProgressPercentage =
                            (double)Globals.StatusBar.ProgressPercentage + ProgressIncrement;
                    }

                    #endregion

                    #region VnUserData

                    foreach (var userData in context.VnUserData.Where(v => v.VnId == Globals.VnId))
                    {
                        if (string.IsNullOrEmpty(userData.LastPlayed))
                        {
                            VnMainModel.LastPlayed = "Never";
                        }
                        else
                        {
                            if ((Convert.ToDateTime(userData.LastPlayed) - DateTime.Today).Days > -7) //need to set to negative, for the difference in days
                            {
                                if (Convert.ToDateTime(userData.LastPlayed) == DateTime.Today)
                                {
                                    VnMainModel.LastPlayed = "Today";
                                }
                                else if ((Convert.ToDateTime(userData.LastPlayed) - DateTime.Today).Days > -2 && (Convert.ToDateTime(userData.LastPlayed) - DateTime.Today).Days < 0)
                                {
                                    VnMainModel.LastPlayed = "Yesterday";
                                }
                                else
                                {
                                    VnMainModel.LastPlayed = Convert.ToDateTime(userData.LastPlayed).DayOfWeek.ToString();
                                }
                            }
                            else
                            {
                                VnMainModel.LastPlayed = userData.LastPlayed;
                            }
                        }



                        string[]   splitPlayTime = userData.PlayTime.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                        List <int> timeList      = new List <int>(4);
                        timeList.AddRange(splitPlayTime.Select(time => Convert.ToInt32(time)));
                        TimeSpan timeSpan = new TimeSpan(timeList[0], timeList[1], timeList[2], timeList[3]);

                        if (timeSpan < new TimeSpan(0, 0, 0, 1))
                        {
                            VnMainModel.PlayTime = "Never";
                        }
                        if (timeSpan < new TimeSpan(0, 0, 0, 60))
                        {
                            VnMainModel.PlayTime = "Less than 1 minute";
                        }
                        else
                        {
                            string formatted =
                                $"{(timeSpan.Duration().Days > 0 ? $"{timeSpan.Days:0} day{(timeSpan.Days == 1 ? string.Empty : "s")}, " : string.Empty)}" +
                                $"{(timeSpan.Duration().Hours > 0 ? $"{timeSpan.Hours:0} hour{(timeSpan.Hours == 1 ? string.Empty : "s")}, " : string.Empty)}" +
                                $"{(timeSpan.Duration().Minutes > 0 ? $"{timeSpan.Minutes:0} minute{(timeSpan.Minutes == 1 ? string.Empty : "s")} " : string.Empty)}";
                            VnMainModel.PlayTime = formatted;
                        }
                    }
                    if (Globals.StatusBar.ProgressPercentage != null)
                    {
                        Globals.StatusBar.ProgressPercentage =
                            (double)Globals.StatusBar.ProgressPercentage + ProgressIncrement;
                    }

                    #endregion
                }
                if (Globals.StatusBar.ProgressPercentage != null)
                {
                    Globals.StatusBar.ProgressPercentage = 100;
                }
                Globals.StatusBar.ProgressText = "Done";
                Task.Delay(1500).Wait();
                Globals.StatusBar.ProgressPercentage = null;
                Globals.StatusBar.IsDbProcessing     = false;
                Globals.StatusBar.IsWorkProcessing   = false;
                Globals.StatusBar.ProgressText       = string.Empty;
            }
            catch (Exception exception)
            {
                Globals.Logger.Error(exception);
                throw;
            }
            finally
            {
                IsMainBinding = false;
            }
        }
コード例 #39
0
 private static void CheckThisItemVersion(Sitecore.Data.Items.Item currentItem, LanguageCollection languageArr, string username, int languageIndex, Database currentDataBase)
 {
     if (Enumerable.Count<Sitecore.Data.Items.Item>((IEnumerable<Sitecore.Data.Items.Item>)currentItem.Versions.GetVersions(true), (Func<Sitecore.Data.Items.Item, bool>)(item => item.Language.Name == languageArr[languageIndex].Name)) != 0)
         return;
     SitecoreHelper.AddVersion(username, currentItem.ID.ToString(), languageIndex, currentDataBase);
 }
コード例 #40
0
        public Dictionary<string, string> GetTranslations(LanguageCollection languages, string value)
        {
            AdmAccessToken admToken;
            string headerValue;
            //Get Client Id and Client Secret from https://datamarket.azure.com/developer/applications/
            //Refer obtaining AccessToken (http://msdn.microsoft.com/en-us/library/hh454950.aspx)
            AdmAuthentication admAuth = new AdmAuthentication("ClientId", "ClientSecret");
            try
            {
                admToken = admAuth.GetAccessToken();
                // Create a header with the access_token property of the returned token
                headerValue = "Bearer " + admToken.access_token;
                TranslateMethod(headerValue, languages, value);
            }
            catch (WebException e)
            {
                ProcessWebException(e);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            return _translations;
        }
コード例 #41
0
        protected override void OnPreRender(EventArgs e)
        {
            StringBuilder warningResult = new StringBuilder();

            //currencies
            if (CurrencyManager.PrimaryExchangeRateCurrency == null)
            {
                warningResult.Append("Primary exchange rate currency is not set. <a href=\"Currencies.aspx\">Set now</a>");
                warningResult.Append("<br />");
                warningResult.Append("<br />");
            }
            if (CurrencyManager.PrimaryStoreCurrency == null)
            {
                warningResult.Append("Primary store currency is not set. <a href=\"Currencies.aspx\">Set now</a>");
                warningResult.Append("<br />");
                warningResult.Append("<br />");
            }

            //measures
            if (MeasureManager.BaseWeightIn == null)
            {
                warningResult.Append("The weight that will can used as a default is not set. <a href=\"GlobalSettings.aspx\">Set now</a>");
                warningResult.Append("<br />");
                warningResult.Append("<br />");
            }
            if (MeasureManager.BaseDimensionIn == null)
            {
                warningResult.Append("The dimension that will can used as a default is not set. <a href=\"GlobalSettings.aspx\">Set now</a>");
                warningResult.Append("<br />");
                warningResult.Append("<br />");
            }

            //languages
            LanguageCollection publishedLanguages = LanguageManager.GetAllLanguages(false);

            foreach (MessageTemplate messageTemplate in MessageManager.GetAllMessageTemplates())
            {
                foreach (Language language in publishedLanguages)
                {
                    LocalizedMessageTemplate localizedMessageTemplate = MessageManager.GetLocalizedMessageTemplate(messageTemplate.Name, language.LanguageId);
                    if (localizedMessageTemplate == null)
                    {
                        warningResult.AppendFormat("You don't have localized version of message template [{0}] for {1}. <a href=\"MessageTemplates.aspx\">Create it now</a>", messageTemplate.Name, language.Name);
                        warningResult.Append("<br />");
                        warningResult.Append("<br />");
                    }
                }
            }
            foreach (Topic topic in TopicManager.GetAllTopics())
            {
                foreach (Language language in publishedLanguages)
                {
                    LocalizedTopic localizedTopic = TopicManager.GetLocalizedTopic(topic.Name, language.LanguageId);
                    if (localizedTopic == null)
                    {
                        warningResult.AppendFormat("You don't have localized version of topic [{0}] for {1}. <a href=\"Topics.aspx\">Create it now</a>", topic.Name, language.Name);
                        warningResult.Append("<br />");
                        warningResult.Append("<br />");
                    }
                }
            }

            //shipping methods
            var srcmList         = ShippingRateComputationMethodManager.GetAllShippingRateComputationMethods(false);
            int offlineSrcmCount = 0;

            foreach (var srcm in srcmList)
            {
                if (srcm.ShippingRateComputationMethodType == ShippingRateComputationMethodTypeEnum.Offline)
                {
                    offlineSrcmCount++;
                }
            }
            if (offlineSrcmCount > 1)
            {
                warningResult.Append("Only one offline shipping rate computation method is recommended to use");
                warningResult.Append("<br />");
                warningResult.Append("<br />");
            }

            string warnings = warningResult.ToString();

            if (!String.IsNullOrEmpty(warnings))
            {
                lblWarnings.Text = warnings;
            }
            else
            {
                this.Visible = false;
            }

            base.OnPreRender(e);
        }
コード例 #42
0
ファイル: LanguageInfo.cs プロジェクト: xingfudaiyan/OA
        /// <summary>
        /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据
        /// </summary>
        /// <param name="pPageIndex">页数</param>
        /// <param name="pPageSize">每页列表</param>
        /// <param name="pOrderBy">排序</param>
        /// <param name="pSortExpression">排序字段</param>
        /// <param name="pRecordCount">列表行数</param>
        /// <returns>数据分页</returns>
        public static List<LanguageInfo> GetPagedList(int pPageIndex,int pPageSize,SortDirection pOrderBy,string pSortExpression,out int pRecordCount)
        {
            if(pPageIndex<=1)
            pPageIndex=1;
            List< LanguageInfo> list = new List< LanguageInfo>();

            Query q = Language .CreateQuery();
            q.PageIndex = pPageIndex;
            q.PageSize = pPageSize;
            q.ORDER_BY(pSortExpression,pOrderBy.ToString());
            LanguageCollection  collection=new  LanguageCollection();
             	collection.LoadAndCloseReader(q.ExecuteReader());

            foreach (Language  language  in collection)
            {
                LanguageInfo languageInfo = new LanguageInfo();
                LoadFromDAL(languageInfo,   language);
                list.Add(languageInfo);
            }
            pRecordCount=q.GetRecordCount();

            return list;
        }
コード例 #43
0
ファイル: LanguageInfo.cs プロジェクト: xingfudaiyan/OA
 /// <summary>
 /// 获得数据列表
 /// </summary>
 /// <returns></returns>
 public static List<LanguageInfo> GetList()
 {
     string cacheKey = GetCacheKey();
     //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取
     if (CachedEntityCommander.IsTypeRegistered(typeof(LanguageInfo)) && CachedEntityCommander.GetCache(cacheKey) != null)
     {
         return CachedEntityCommander.GetCache(cacheKey) as List< LanguageInfo>;
     }
     else
     {
         List< LanguageInfo>  list =new List< LanguageInfo>();
         LanguageCollection  collection=new  LanguageCollection();
         Query qry = new Query(Language.Schema);
         collection.LoadAndCloseReader(qry.ExecuteReader());
         foreach(Language language in collection)
         {
             LanguageInfo languageInfo= new LanguageInfo();
             LoadFromDAL(languageInfo,language);
             list.Add(languageInfo);
         }
       	//生成缓存
         if (CachedEntityCommander.IsTypeRegistered(typeof(LanguageInfo)))
         {
             CachedEntityCommander.SetCache(cacheKey, list);
         }
         return list;
     }
 }
コード例 #44
0
        void LoadLanguages()
        {
            SuspendLayout();
            lbFrom.Items.Clear();
            lbTo.Items.Clear();

            LanguageCollection fromLangs = new LanguageCollection();
            LanguageCollection toLangs = new LanguageCollection();

            foreach(LanguagePair lp in Manager.LanguagePairServiceItems.Keys)
            {
                if(!fromLangs.Contains(lp.From))
                    fromLangs.Add(lp.From);

                if(!toLangs.Contains(lp.To))
                    toLangs.Add(lp.To);
            }

            fromLangs.Sort();

            string val = "";
            int idx;

            val = "+" + TranslateString("Toggle all");
            lbFrom.Items.Add(new LanguageDataContainer(Language.Any, val));

            foreach(Language l in fromLangs)
            {
                val = LangPack.TranslateLanguage(l);
                idx = lbFrom.Items.Add(new LanguageDataContainer(l, val));
                lbFrom.SetItemChecked(idx, !profile.DisabledSourceLanguages.Contains(l));
            }

            lbFrom.SetItemChecked(0, lbFrom.CheckedItems.Count == fromLangs.Count);

            if(lbFrom.Items.Count > 0)
                lbFrom.SelectedIndex = 0;

            toLangs.Sort();

            val = "+" + TranslateString("Toggle all");
            lbTo.Items.Add(new LanguageDataContainer(Language.Any, val));

            foreach(Language l in toLangs)
            {
                val = LangPack.TranslateLanguage(l);
                idx = lbTo.Items.Add(new LanguageDataContainer(l, val));
                lbTo.SetItemChecked(idx, !profile.DisabledTargetLanguages.Contains(l));
            }

            lbTo.SetItemChecked(0, lbTo.CheckedItems.Count == toLangs.Count);

            if(lbTo.Items.Count > 0)
                lbTo.SelectedIndex = 0;

            ResumeLayout(true);
        }
コード例 #45
0
        public LanguageCollection LoadLanguages()
        {
            var languages = Provider.GetItemsByTemplate(TemplateIDs.Language.Guid);

            LanguageCollection languageCollection = new LanguageCollection();

            foreach (var language in languages.Where(x=>!string.IsNullOrEmpty(x.Name)))
            {
                Language result;
                if (Language.TryParse(language.Name, out result) && !languageCollection.Contains(result))
                {
                    result.Origin.ItemId = new ID(language.Id);
                    languageCollection.Add(result);
                }
            }
            return languageCollection;
        }
コード例 #46
0
        private static void ProcessNonSiteItem(Item item, GetContentEditorWarningsArgs args)
        {
            Version[] versionNumbers = item.Versions.GetVersionNumbers(false);
            if (versionNumbers != null && versionNumbers.Length > 0)
            {
                return;
            }

            LanguageCollection languages = LanguageManager.GetLanguages(Sitecore.Context.ContentDatabase);
            int lancount     = 0;
            var languageList = new List <string>();

            foreach (Language language in languages)
            {
                if (HasLanguage(item, language))
                {
                    lancount++;
                    languageList.Add(language.ToString());
                    if (lancount > 3)
                    {
                        //limit to 4, but add en if precent because this is the default
                        if (!languageList.Contains("en"))
                        {
                            var defaultlang = Sitecore.Globalization.Language.Parse("en");
                            if (defaultlang != null && HasLanguage(item, defaultlang))
                            {
                                languageList.Add(defaultlang.ToString());
                            }
                        }
                        break;
                    }
                }
            }
            if (languageList.Any())
            {
                GetContentEditorWarningsArgs.ContentEditorWarning contentEditorWarning = args.Add();
                contentEditorWarning.Title =
                    string.Format(Translate.Text("The current item does not have a version in \"{0}\"."),
                                  (object)item.Language.GetDisplayName());
                if (item.Access.CanWriteLanguage() && item.Access.CanWrite())
                {
                    contentEditorWarning.Text =
                        Translate.Text("To create a version, click Add a New Version or Switch language.");
                    contentEditorWarning.AddOption(Translate.Text("Add a new version."), "item:addversion");
                    foreach (var languageitem in languageList)
                    {
                        contentEditorWarning.AddOption(string.Format("Switch to {0}", languageitem), string.Format(CultureInfo.InvariantCulture, "item:load(id={0},language={1})", item.ID, languageitem));
                    }
                    contentEditorWarning.IsExclusive = true;
                }
                else
                {
                    contentEditorWarning.IsExclusive = false;
                }
                contentEditorWarning.HideFields = true;
                contentEditorWarning.Key        = HasNoVersions.Key;
            }
            else
            {
                GetContentEditorWarningsArgs.ContentEditorWarning contentEditorWarning = args.Add();
                contentEditorWarning.Title =
                    string.Format(Translate.Text("The current item does not have a version in \"{0}\"."),
                                  (object)item.Language.GetDisplayName());
                if (item.Access.CanWriteLanguage() && item.Access.CanWrite())
                {
                    contentEditorWarning.Text =
                        Translate.Text("To create a version, click Add a New Version or click Add on the Versions tab.");
                    contentEditorWarning.AddOption(Translate.Text("Add a new version."), "item:addversion");
                    contentEditorWarning.IsExclusive = true;
                }
                else
                {
                    contentEditorWarning.IsExclusive = false;
                }
                contentEditorWarning.HideFields = true;
                contentEditorWarning.Key        = HasNoVersions.Key;
            }
        }
コード例 #47
0
        public ActionResult list()
        {
            LanguageCollection collection = LanguageManager.GetAll(CurrentUser.CompanyID);

            return(View(ViewFolder + "list.cshtml", collection));
        }
コード例 #48
0
 /// <summary>
 /// Initializes the <see cref="T:LanguageLoader"/> class.
 /// </summary>
 static LanguageLoader()
 {
     languageCollection = Resources.Load("Localization") as LanguageCollection;
 }
コード例 #49
0
        protected void BindData()
        {
            StringBuilder warningResult = new StringBuilder();

            if (CurrencyManager.PrimaryExchangeRateCurrency == null)
            {
                warningResult.Append("Primary exchange rate currency is not set. <a href=\"Currencies.aspx\">Set now</a>");
                warningResult.Append("<br />");
                warningResult.Append("<br />");
            }

            if (CurrencyManager.PrimaryStoreCurrency == null)
            {
                warningResult.Append("Primary store currency is not set. <a href=\"Currencies.aspx\">Set now</a>");
                warningResult.Append("<br />");
                warningResult.Append("<br />");
            }

            if (MeasureManager.BaseWeightIn == null)
            {
                warningResult.Append("The weight that will can used as a default is not set. <a href=\"GlobalSettings.aspx\">Set now</a>");
                warningResult.Append("<br />");
                warningResult.Append("<br />");
            }

            if (MeasureManager.BaseDimensionIn == null)
            {
                warningResult.Append("The dimension that will can used as a default is not set. <a href=\"GlobalSettings.aspx\">Set now</a>");
                warningResult.Append("<br />");
                warningResult.Append("<br />");
            }

            LanguageCollection publishedLanguages = LanguageManager.GetAllLanguages(false);

            foreach (MessageTemplate messageTemplate in MessageManager.GetAllMessageTemplates())
            {
                foreach (Language language in publishedLanguages)
                {
                    LocalizedMessageTemplate localizedMessageTemplate = MessageManager.GetLocalizedMessageTemplate(messageTemplate.Name, language.LanguageID);
                    if (localizedMessageTemplate == null)
                    {
                        warningResult.AppendFormat("You don't have localized version of message template [{0}] for {1}. <a href=\"MessageTemplates.aspx\">Create it now</a>", messageTemplate.Name, language.Name);
                        warningResult.Append("<br />");
                        warningResult.Append("<br />");
                    }
                }
            }

            foreach (Topic topic in TopicManager.GetAllTopics())
            {
                foreach (Language language in publishedLanguages)
                {
                    LocalizedTopic localizedTopic = TopicManager.GetLocalizedTopic(topic.Name, language.LanguageID);
                    if (localizedTopic == null)
                    {
                        warningResult.AppendFormat("You don't have localized version of topic [{0}] for {1}. <a href=\"Topics.aspx\">Create it now</a>", topic.Name, language.Name);
                        warningResult.Append("<br />");
                        warningResult.Append("<br />");
                    }
                }
            }

            string warnings = warningResult.ToString();

            if (!String.IsNullOrEmpty(warnings))
            {
                lblWarnings.Text = warnings;
            }
            else
            {
                this.Visible = false;
            }
        }
コード例 #50
0
ファイル: Language.ascx.cs プロジェクト: NCIOCPL/pubslocator
        protected void gvResult_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            LanguageCollection dt = ((LanguageCollection)this.gvResult.DataSource);

            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                PubEntAdmin.BLL.Language l_conf = dt[e.Item.ItemIndex];
                ((Label)e.Item.Cells[1].Controls[1]).Text = Server.HtmlEncode(l_conf.LngName);


                //delete btn col
                Button l_able = e.Item.Cells[5].FindControl("lnkbtnDel") as Button;

                if (l_conf.Checked)
                {
                    ((Label)e.Item.Cells[2].Controls[1]).Text = "Active";
                    l_able.Text = "Inactivate";
                    Panel l_pnl = e.Item.Cells[5].FindControl("pnlConfirmDel") as Panel;
                    ((Label)l_pnl.Controls[1]).Text = "Are you sure you want to inactivate this Lookup Value [" + Server.HtmlEncode(l_conf.LngName) + "]?";
                }
                else
                {
                    ((Label)e.Item.Cells[2].Controls[1]).Text = "Inactive";
                    l_able.Text = "Activate";
                    Panel l_pnl = e.Item.Cells[5].FindControl("pnlConfirmDel") as Panel;
                    ((Label)l_pnl.Controls[1]).Text = "Are you sure you want to activate this Lookup Value [" + Server.HtmlEncode(l_conf.LngName) + "]?";
                }
            }
            else if (e.Item.ItemType == ListItemType.EditItem)
            {
                PubEntAdmin.BLL.Language l_conf = dt[e.Item.ItemIndex];
                String status = "";
                if (l_conf.Checked == true)
                {
                    status = "Active";
                }
                else
                {
                    status = "Inactive";
                }
                ((Label)e.Item.Cells[2].Controls[1]).Text = status;

                if (e.Item.Cells[3].Controls[2] is Button)
                {
                    Button l_btnCancel = ((Button)e.Item.Cells[3].Controls[2]);
                    l_btnCancel.ID = "gvResult_Cancel";

                    Panel l_panel = new Panel();
                    l_panel.ID       = "l_panel";
                    l_panel.CssClass = "modalPopup";
                    l_panel.Style.Add("display", "none");
                    l_panel.Width = Unit.Pixel(233);

                    Label l_label = new Label();
                    l_label.Text = "Are you sure you want to continue?";

                    HtmlGenericControl l_div    = new HtmlGenericControl();
                    Button             l_ok     = new Button();
                    Button             l_cancel = new Button();
                    l_ok.ID       = "l_ok";
                    l_ok.Text     = "OK";
                    l_cancel.ID   = "l_cancel";
                    l_cancel.Text = "Cancel";
                    l_div.Controls.Add(l_ok);
                    l_div.Controls.Add(new LiteralControl("&nbsp;"));
                    l_div.Controls.Add(l_cancel);
                    l_div.Attributes.Add("align", "center");

                    l_panel.Controls.Add(l_label);
                    l_panel.Controls.Add(new LiteralControl("<br>"));
                    l_panel.Controls.Add(new LiteralControl("<br>"));
                    l_panel.Controls.Add(l_div);

                    ModalPopupExtender l_mpe = new ModalPopupExtender();
                    l_mpe.ID = "l_mpe";
                    l_mpe.TargetControlID    = l_btnCancel.ID;
                    l_mpe.PopupControlID     = l_panel.ID;
                    l_mpe.BackgroundCssClass = "modalBackground";
                    l_mpe.DropShadow         = true;
                    l_mpe.OkControlID        = l_ok.ID;
                    l_mpe.CancelControlID    = l_cancel.ID;

                    ConfirmButtonExtender l_cbe = new ConfirmButtonExtender();
                    l_cbe.TargetControlID     = l_btnCancel.ID;
                    l_cbe.ConfirmText         = "";
                    l_cbe.DisplayModalPopupID = l_mpe.ID;

                    e.Item.Cells[3].Controls.Add(l_panel);
                    e.Item.Cells[3].Controls.Add(l_mpe);
                    e.Item.Cells[3].Controls.Add(l_cbe);
                }

                //delete btn col
                Button l_able = e.Item.Cells[5].FindControl("lnkbtnDel") as Button;

                if (l_conf.Checked)
                {
                    ((Label)e.Item.Cells[2].Controls[1]).Text = "Active";
                    l_able.Text = "Inactivate";
                    Panel l_pnl = e.Item.Cells[5].FindControl("pnlConfirmDel") as Panel;
                    ((Label)l_pnl.Controls[1]).Text = "Are you sure you want to inactivate this Lookup Value [" + Server.HtmlEncode(l_conf.LngName) + "]?";
                }
                else
                {
                    ((Label)e.Item.Cells[2].Controls[1]).Text = "Inactive";
                    l_able.Text = "Activate";
                    Panel l_pnl = e.Item.Cells[5].FindControl("pnlConfirmDel") as Panel;
                    ((Label)l_pnl.Controls[1]).Text = "Are you sure you want to activate this Lookup Value [" + Server.HtmlEncode(l_conf.LngName) + "]?";
                }
            }
        }
コード例 #51
0
        void LbFromSelectedIndexChanged(object sender, EventArgs e)
        {
            LockUpdate(true);
            if(lbFrom.SelectedIndex == -1)
                return;

            Language fromLanguage = ((LanguageDataContainer)lbFrom.SelectedItem).Language;
            LanguageDataContainer toLanguage = null;
            if(lbTo.SelectedItem != null)
                toLanguage = ((LanguageDataContainer)lbTo.SelectedItem);

            lbTo.BeginUpdate();

            lbTo.Items.Clear();

            LanguageCollection toLangs = new LanguageCollection();
            int index;
            foreach(LanguagePair lp in languages)
            {
                if((lp.From == fromLanguage || fromLanguage == Language.Any))
                {
                    index = toLangs.BinarySearch(lp.To);
                    if(index < 0)
                        toLangs.Insert(~index, lp.To);
                }
            }

            string val = "";

            if(toLangs.Count > 1)
            {
                val = "+" + LangPack.TranslateLanguage(Language.Any);
                lbTo.Items.Add(new LanguageDataContainer(Language.Any, val));
            }

            foreach(Language l in toLangs)
            {
                val = LangPack.TranslateLanguage(l);
                lbTo.Items.Add(new LanguageDataContainer(l, val));
            }
            lbTo.EndUpdate();

            string caption = LangPack.TranslateLanguage(fromLanguage);
            lFrom.Text = caption;

            int idx = -1;
            if(toLanguage != null)
                idx = lbTo.Items.IndexOf(toLanguage);

            if(idx == -1)
                idx = 0;
            lbTo.SelectedIndex = idx;
            LockUpdate(false);
        }
コード例 #52
0
ファイル: LanguageInfo.cs プロジェクト: xingfudaiyan/OA
 /// <summary>
 /// 批量装载
 /// </summary>
 internal static void LoadFromDALPatch(List< LanguageInfo> pList, LanguageCollection pCollection)
 {
     foreach (Language language in pCollection)
     {
         LanguageInfo languageInfo = new LanguageInfo();
         LoadFromDAL(languageInfo, language );
         pList.Add(languageInfo);
     }
 }
コード例 #53
0
        ////////////////////////МЕНЮ\\\\\\\\\\\\\\\\\\\\\\


        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            context = Application.Context;
            ISharedPreferences       prefs  = PreferenceManager.GetDefaultSharedPreferences(context);
            ISharedPreferencesEditor editor = prefs.Edit();

            languagesId = prefs.GetInt("key_languageId", 1);

            if (languagesId == 1)
            {
                LanguageCodevalue = "en";
            }
            else
            if (languagesId == 2)
            {
                LanguageCodevalue = "fr";
            }
            else
            if (languagesId == 3)
            {
                LanguageCodevalue = "de";
            }
            else
            if (languagesId == 4)
            {
                LanguageCodevalue = "it";
            }
            else
            if (languagesId == 5)
            {
                LanguageCodevalue = "es";
            }
            else
            if (languagesId == 6)
            {
                LanguageCodevalue = "pt";
            }
            else
            if (languagesId == 7)
            {
                LanguageCodevalue = "cs";
            }
            else
            if (languagesId == 8)
            {
                LanguageCodevalue = "pl";
            }
            else
            if (languagesId == 9)
            {
                LanguageCodevalue = "ru";
            }
            else
            if (languagesId == 10)
            {
                LanguageCodevalue = "uk";
            }
            else
            if (languagesId == 11)
            {
                LanguageCodevalue = "ja";
            }
            else
            if (languagesId == 12)
            {
                LanguageCodevalue = "ko";
            }

            Android.Content.Res.Resources res = this.Resources;
            DisplayMetrics Dm = res.DisplayMetrics;

            Android.Content.Res.Configuration conf = res.Configuration;
            if (LanguageCodevalue != null)
            {
                conf.SetLocale(new Locale(LanguageCodevalue));
            }
            else
            {
                conf.SetLocale(new Locale("en"));
            }
            res.UpdateConfiguration(conf, Dm);

            SetContentView(Resource.Layout.Dedoherzer);

            ////////////////////////МЕНЮ\\\\\\\\\\\\\\\\\\\\\\
            drawerLayout = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
            var toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id._app_bar);

            SetSupportActionBar(toolbar);
            SupportActionBar.SetTitle(Resource.String.app_name);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetDisplayShowHomeEnabled(true);
            var navigationView = FindViewById <NavigationView>(Resource.Id.nav_view);

            navigationView.NavigationItemSelected += NavigationView_NavigationItemSelected;
            var drawerToogle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, Resource.String.open_drawer, Resource.String.close_drawer);

            drawerLayout.AddDrawerListener(drawerToogle);
            drawerToogle.SyncState();
            ////////////////////////МЕНЮ\\\\\\\\\\\\\\\\\\\\\\ 

            #region Прив'язка

            switchKMHToMPH       = FindViewById <Switch>(Resource.Id.settingsSwitchKMHToMPH);
            buttonApply          = FindViewById <Button>(Resource.Id.settingsButtonApply);
            languageSpiner       = FindViewById <Spinner>(Resource.Id.languageSpiner);
            firstActivitySpinner = FindViewById <Spinner>(Resource.Id.firstActivitySpiner);

            ButtonReddit      = FindViewById <Button>(Resource.Id.buttonReddit);
            ButtonDiscord     = FindViewById <Button>(Resource.Id.buttonDiscord);
            ButtonEmail       = FindViewById <Button>(Resource.Id.buttonEMail);
            RatingBar         = FindViewById <RatingBar>(Resource.Id.ratingBar);
            ButtonAboutTheApp = FindViewById <Button>(Resource.Id.settingsAboutTheAppButton);

            #endregion

            #region Запам'ятовування перемикача км/г в миль/г

            switchKMHToMPH.Checked = prefs.GetBoolean("key_kmhtomph", false);
            #endregion

            #region Вибір мови

            languages              = LanguageCollection.GetLanguages();
            AdapterLanguage        = new LanguageAdapter(this, languages);
            languageSpiner.Adapter = AdapterLanguage;
            languagesId            = prefs.GetInt("key_languageId", 1);
            languageSpiner.SetSelection(languagesId - 1);  //Автовыбор

            languageSpiner.ItemSelected += LanguageSpiner_ItemSelected;

            #endregion

            #region Вибір актівіті

            firstActivities              = FirstActivityCollection.GetFirstActivitys();
            AdapterFirstActivity         = new FirstActivityAdapter(this, firstActivities);
            firstActivitySpinner.Adapter = AdapterFirstActivity;
            firstActivityId              = prefs.GetInt("key_firstActivityId", 1);

            firstActivitySpinner.ItemSelected += FirstActivitySpinner_ItemSelected;
            #endregion

            #region Кнопка застосувати

            buttonApply.Click += (sender, e) =>
            {
                if (switchKMHToMPH.Checked == true)
                {
                    editor.PutBoolean("key_kmhtomph", true);
                    editor.Apply();
                }
                else
                {
                    editor.PutBoolean("key_kmhtomph", false);
                    editor.Apply();
                }

                if (languagesId == 1)
                {
                    LanguageCodevalue = "en";
                }
                else
                if (languagesId == 2)
                {
                    LanguageCodevalue = "ru";
                }
                if (languagesId == 3)
                {
                    LanguageCodevalue = "uk";
                }
                this.Recreate();
                Toast.MakeText(context, context.Resources.GetString(Resource.String.SettingsApplied), ToastLength.Short).Show();
            };
            #endregion


            ButtonReddit.Click        += ButtonReddit_Click;
            ButtonDiscord.Click       += ButtonDiscord_Click;
            ButtonEmail.Click         += ButtonEmail_Click;
            ButtonAboutTheApp.Click   += ButtonAboutTheApp_Click;
            RatingBar.RatingBarChange += RatingBar_RatingBarChange;
        }
コード例 #54
0
ファイル: Language.cs プロジェクト: hondoslack/territorysite
 public static LanguageCollection GetForCurrentAccount()
 {
     LanguageCollection collection = new LanguageCollection();
     collection.LoadAndCloseReader(SPs.CmsLanguageGetByAccountId(CurrentUser.CurrentAccount.AccountId).GetReader());
     return collection;
 }
コード例 #55
0
        private void TranslateMethod(string authToken, LanguageCollection languages, string value)
        {
            string from = "en";
            string translation;
            HttpWebRequest httpWebRequest;
            WebResponse response = null;

            try
            {

                foreach (var language in languages.Languages)
                {
                    string uri = "http://api.microsofttranslator.com/v2/Http.svc/Translate?text=" +
                        HttpUtility.UrlEncode(value) + "&from=" + from + "&to=" + language.Key;
                    httpWebRequest = (HttpWebRequest)WebRequest.Create(uri);
                    httpWebRequest.Headers.Add("Authorization", authToken);
                    response = null;
                    response = httpWebRequest.GetResponse();
                    using (Stream stream = response.GetResponseStream())
                    {
                        var dcs = new System.Runtime.Serialization.DataContractSerializer(Type.GetType("System.String"));
                        translation = (string)dcs.ReadObject(stream);
                    }

                    _translations.Add(language.Key, translation);
                }

            }
            catch
            {
                throw;
            }
            finally
            {
                if (response != null)
                {
                    response.Close();
                    response = null;
                }
            }
        }