• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Localization类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Localization的典型用法代码示例。如果您正苦于以下问题:C# Localization类的具体用法?C# Localization怎么用?C# Localization使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Localization类属于命名空间,在下文中一共展示了Localization类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: OnLocalize

    /// <summary>
    /// This function is called by the Localization manager via a broadcast SendMessage.
    /// </summary>
    void OnLocalize(Localization loc)
    {
        if (mLanguage != loc.currentLanguage)
        {
            UIWidget w = GetComponent<UIWidget>();
            UILabel lbl = w as UILabel;
            UISprite sp = w as UISprite;

            // If no localization key has been specified, use the label's text as the key
            if (string.IsNullOrEmpty(mLanguage) && string.IsNullOrEmpty(key) && lbl != null) key = lbl.text;

            // If we still don't have a key, use the widget's name
            string val = string.IsNullOrEmpty(key) ? loc.Get(w.name) : loc.Get(key);

            if (lbl != null)
            {
                lbl.text = val;
            }
            else if (sp != null)
            {
                sp.spriteName = val;
                sp.MakePixelPerfect();
            }
            mLanguage = loc.currentLanguage;
        }
    }
开发者ID:rmkeezer,项目名称:fpsgame,代码行数:29,代码来源:UILocalize.cs


示例2: BuildEntityModel

        public virtual void BuildEntityModel(ref EntityModel entityModel, IComponentPresentation cp, Localization localization)
        {
            using (new Tracer(entityModel, cp, localization))
            {
                MvcData mvcData = GetMvcData(cp);
                Type modelType = ModelTypeRegistry.GetViewModelType(mvcData);

                // NOTE: not using ModelBuilderPipeline here, but directly calling our own implementation.
                BuildEntityModel(ref entityModel, cp.Component, modelType, localization);

                entityModel.XpmMetadata.Add("ComponentTemplateID", cp.ComponentTemplate.Id);
                entityModel.XpmMetadata.Add("ComponentTemplateModified", cp.ComponentTemplate.RevisionDate.ToString("yyyy-MM-ddTHH:mm:ss"));
                entityModel.XpmMetadata.Add("IsRepositoryPublished", cp.IsDynamic ? "true" : "false");
                entityModel.MvcData = mvcData;

                // add html classes to model from metadata
                // TODO: move to CreateViewModel so it can be merged with the same code for a Page/PageTemplate
                IComponentTemplate template = cp.ComponentTemplate;
                if (template.MetadataFields != null && template.MetadataFields.ContainsKey("htmlClasses"))
                {
                    // strip illegal characters to ensure valid html in the view (allow spaces for multiple classes)
                    entityModel.HtmlClasses = template.MetadataFields["htmlClasses"].Value.StripIllegalCharacters(@"[^\w\-\ ]");
                }

                if (cp.IsDynamic)
                {
                    // update Entity Identifier to that of a DCP
                    entityModel.Id = GetDxaIdentifierFromTcmUri(cp.Component.Id, cp.ComponentTemplate.Id);
                }
            }
        }
开发者ID:ginortoro,项目名称:dxa-web-application-dotnet,代码行数:31,代码来源:DefaultModelBuilder.cs


示例3: AddLocalization

        /// <summary>
        /// Add a localization file.
        /// </summary>
        /// <param name="localization">The localization file to add.</param>
        public void AddLocalization(Localization localization)
        {
            if (-1 == this.codepage)
            {
                this.codepage = localization.Codepage;
            }

            foreach (WixVariableRow wixVariableRow in localization.Variables)
            {
                WixVariableRow existingWixVariableRow = (WixVariableRow)this.variables[wixVariableRow.Id];

                if (null == existingWixVariableRow || (existingWixVariableRow.Overridable && !wixVariableRow.Overridable))
                {
                    this.variables[wixVariableRow.Id] = wixVariableRow;
                }
                else if (!wixVariableRow.Overridable)
                {
                    this.OnMessage(WixErrors.DuplicateLocalizationIdentifier(wixVariableRow.SourceLineNumbers, wixVariableRow.Id));
                }
            }

            foreach (KeyValuePair<string, LocalizedControl> localizedControl in localization.LocalizedControls)
            {
                if (!this.localizedControls.ContainsKey(localizedControl.Key))
                {
                    this.localizedControls.Add(localizedControl.Key, localizedControl.Value);
                }
            }
        }
开发者ID:bullshock29,项目名称:Wix3.6Toolset,代码行数:33,代码来源:Localizer.cs


示例4: DubizzleURIBuilder

 public DubizzleURIBuilder(HTTPProtocol protocol, Localization location, MainSection section)
 {
     Location = location ;
     Protocol = protocol;
     Section = section;
     this.Url = new Uri(string.Format("{0}{1}.{2}/{3}", _protocolString, _locationString, baseuri, _sectionString));
 }
开发者ID:rkrishnasanka,项目名称:Dubizzle,代码行数:7,代码来源:DubizzleURI.cs


示例5: OnLocalize

 private void OnLocalize(Localization loc)
 {
     if (this.mLanguage != loc.currentLanguage)
     {
         this.Localize();
     }
 }
开发者ID:Lessica,项目名称:Something-of-SHIPWAR-GAMES,代码行数:7,代码来源:UILocalize.cs


示例6: Build

 public LocalizationViewModel Build(Localization localization)
 {
     return new LocalizationViewModel()
       {
     Culture = new CultureViewModelBuilder(this.handler).Build(localization.Culture),
     Value = localization.Value
       };
 }
开发者ID:blink2linkme,项目名称:Platformus,代码行数:8,代码来源:LocalizationViewModelBuilder.cs


示例7: App

		public App ()
		{
			InitializeComponent ();
			Localization = new Localization ();
			Preferences = DependencyService.Get<IPreferences> ();

			MainPage = new ContentPage ();
		}
开发者ID:arctouch-douglaskazumi,项目名称:ArcTouchPark,代码行数:8,代码来源:App.xaml.cs


示例8: Localize

 public string Localize(Localization.rowIds in_textID)
 {
     var row = Localization.Instance.GetRow(in_textID);
     if (row != null)
     {
         return row.GetStringData(EditorLanguage);
     }
     return "Unable to find string ID: " + in_textID;
 }
开发者ID:joenarus,项目名称:Stressident,代码行数:9,代码来源:Google2u.cs


示例9: GetCachedFile

        /// <summary>
        /// Gets the cached local file for a given URL path.
        /// </summary>
        /// <param name="urlPath">The URL path.</param>
        /// <param name="localization">The Localization.</param>
        /// <returns>The path to the local file.</returns>
        internal string GetCachedFile(string urlPath, Localization localization)
        {
            string localFilePath = GetFilePathFromUrl(urlPath, localization);
            using (new Tracer(urlPath, localization, localFilePath))
            {
                Dimensions dimensions;
                urlPath = StripDimensions(urlPath, out dimensions);
                int publicationId = Convert.ToInt32(localization.LocalizationId);

                DateTime lastPublishedDate = SiteConfiguration.CacheProvider.GetOrAdd(
                    urlPath,
                    CacheRegions.BinaryPublishDate,
                    () => GetBinaryLastPublishDate(urlPath, publicationId)
                    );

                if (lastPublishedDate != DateTime.MinValue)
                {
                    if (File.Exists(localFilePath))
                    {
                        if (localization.LastRefresh.CompareTo(lastPublishedDate) < 0)
                        {
                            //File has been modified since last application start but we don't care
                            Log.Debug("Binary with URL '{0}' is modified, but only since last application restart, so no action required", urlPath);
                            return localFilePath;
                        }
                        FileInfo fi = new FileInfo(localFilePath);
                        if (fi.Length > 0)
                        {
                            DateTime fileModifiedDate = File.GetLastWriteTime(localFilePath);
                            if (fileModifiedDate.CompareTo(lastPublishedDate) >= 0)
                            {
                                Log.Debug("Binary with URL '{0}' is still up to date, no action required", urlPath);
                                return localFilePath;
                            }
                        }
                    }
                }

                // Binary does not exist or cached binary is out-of-date
                BinaryMeta binaryMeta = GetBinaryMeta(urlPath, publicationId);
                if (binaryMeta == null)
                {
                    // Binary does not exist in Tridion, it should be removed from the local file system too
                    if (File.Exists(localFilePath))
                    {
                        CleanupLocalFile(localFilePath);
                    }
                    throw new DxaItemNotFoundException(urlPath, localization.LocalizationId);
                }
                BinaryFactory binaryFactory = new BinaryFactory();
                BinaryData binaryData = binaryFactory.GetBinary(publicationId, binaryMeta.Id, binaryMeta.VariantId);

                WriteBinaryToFile(binaryData.Bytes, localFilePath, dimensions);
                return localFilePath;
            }
        }
开发者ID:sdl,项目名称:dxa-web-application-dotnet,代码行数:62,代码来源:BinaryFileManager.cs


示例10: SetupParameters

        protected virtual NameValueCollection SetupParameters(SearchQuery searchQuery, Localization localization)
        {
            NameValueCollection result = new NameValueCollection(searchQuery.QueryStringParameters);
            result["fq"] = "publicationid:" + localization.LocalizationId;
            result["q"] = searchQuery.QueryText;
            result["start"] = searchQuery.Start.ToString(CultureInfo.InvariantCulture);
            result["rows"] = searchQuery.PageSize.ToString(CultureInfo.InvariantCulture);

            return result;
        }
开发者ID:RAJMITTAL,项目名称:dxa-modules,代码行数:10,代码来源:SI4TSearchProvider.cs


示例11: GetSearchIndexUrl

 protected virtual string GetSearchIndexUrl(Localization localization)
 {
     // First try the new search.queryURL setting provided by DXA 1.3 TBBs if the Search Query URL can be obtained from Topology Manager.
     string result = localization.GetConfigValue("search.queryURL");
     if (string.IsNullOrEmpty(result))
     {
         result = localization.GetConfigValue("search." + (localization.IsStaging ? "staging" : "live") + "IndexConfig");
     }
     return result;
 }
开发者ID:sdl,项目名称:dxa-modules,代码行数:10,代码来源:SI4TSearchProvider.cs


示例12: Start

    // Use this for initialization
    void Start()
    {
        m_Localization = DcGame.getInstance ().transform.FindChild ("Localization(Clone)").GetComponent (typeof(Localization)) as Localization;
        if (m_Localization == null){
            Debug.LogError("CAN'T FIND LOCALIZATION FILE");
        }
        //m_Localization.currentLanguage = "cn";

        m_IsInit = true;
    }
开发者ID:aminebenali,项目名称:dancing-cell-code,代码行数:11,代码来源:NvLocalizationManager.cs


示例13: Create

        /// <summary>
        /// Laedt das Formular zum Eintragen einer Trainingseinheit
        /// </summary>
        /// <param name="id">ID des Trainingsplans, fuer den die Trainingseinheit erstellt werden soll</param>
        /// <returns></returns>
        public ActionResult Create(int id)
        {
            RedirectIfNotLoggedIn();

            ml_WorkoutPlan model = _workoutService.Load(id);

            ILocalization loc = new Localization();
            ViewData["DateFormat"] = loc.GetjQueryDatepickerFormat();

            return View(model);
        }
开发者ID:m-boldt,项目名称:Exercise-Yourself,代码行数:16,代码来源:SessionController.cs


示例14: AddLocalization

 /// <summary>
 /// Add a localization file to this library.
 /// </summary>
 /// <param name="localization">The localization file to add.</param>
 public void AddLocalization(Localization localization)
 {
     if (!this.localizations.Contains(localization.Culture))
     {
         this.localizations.Add(localization.Culture, localization);
     }
     else
     {
         Localization existingCulture = (Localization)this.localizations[localization.Culture];
         existingCulture.Merge(localization);
     }
 }
开发者ID:zooba,项目名称:wix3,代码行数:16,代码来源:Library.cs


示例15: GetPrefix

 /// <summary>
 /// Gets prefix for semantic vocabulary.
 /// </summary>
 /// <param name="vocab">Vocabulary name</param>
 /// <param name="loc">The localization</param>
 /// <returns>Prefix for this semantic vocabulary</returns>
 public static string GetPrefix(string vocab, Localization loc)
 {
     string key = loc.LocalizationId;
     if (!_semanticVocabularies.ContainsKey(key) || SiteConfiguration.CheckSettingsNeedRefresh(_vocabSettingsType, loc))
     {
         LoadVocabulariesForLocalization(loc);
     }
     if (_semanticVocabularies.ContainsKey(key))
     {
         List<SemanticVocabulary> vocabs = _semanticVocabularies[key];
         return GetPrefix(vocabs, vocab);
     }
     Log.Error("Localization {0} does not contain vocabulary {1}. Check that the Publish Settings page is published and the application cache is up to date.", loc.LocalizationId, vocab);
     return null;
 }
开发者ID:tgfl-tom,项目名称:dxa-web-application-dotnet,代码行数:21,代码来源:SemanticMapping.cs


示例16: ExportStandardText

        public virtual void ExportStandardText(Localization localization)
        {
            string path = EditorUtility.SaveFilePanel("Export Standard Text", "Assets/", "standard.txt", "");
            if (path.Length == 0) 
            {
                return;
            }

            localization.ClearLocalizeableCache();

            string textData = localization.GetStandardText();           
            File.WriteAllText(path, textData);
            AssetDatabase.Refresh();

            ShowNotification(localization);
        }
开发者ID:abstractmachine,项目名称:Fungus-3D-Template,代码行数:16,代码来源:LocalizationEditor.cs


示例17: Resources

 public IDictionary Resources(Localization localization)
 {
     string key = localization.LocalizationId;
     //Load resources if they are not already loaded, or if they are out of date and need refreshing
     if (!_resources.ContainsKey(key) || SiteConfiguration.CheckSettingsNeedRefresh(_settingsType, localization))
     {
         LoadResourcesForLocalization(localization);
         if (!_resources.ContainsKey(key))
         {
             Exception ex = new Exception(String.Format("No resources can be found for localization {0}. Check that the localization path is correct and the resources have been published.", localization.LocalizationId));
             Log.Error(ex);
             throw ex;
         }
     }
     return _resources[key];
 }
开发者ID:tgfl-tom,项目名称:dxa-web-application-dotnet,代码行数:16,代码来源:ResourceProvider.cs


示例18: Awake

    // Use this for initialization
    void Awake()
    {
        if (Instance != null && Instance != this) {
            //destroy other instances
            Destroy(gameObject);
            return;
        }

        //Singleton instance
        Instance = this;

        //on't destroy between scenes
        DontDestroyOnLoad(gameObject);

        if (SourceFile == null) {
            this.enabled = false;
            return;
        }
        _localizationDictionary = new Dictionary<string, Dictionary<string, string>>();

        UpdateDictionary();

        //new List<MainMenu_Settings>(Resources.FindObjectsOfTypeAll<MainMenu_Settings>()).ForEach(i => i.gameObject.SetActive(true));

        var dropdownObject = new List<Dropdown>(Resources.FindObjectsOfTypeAll<Dropdown>()).Find(i => i.name == "LanguageSelect");
        if (dropdownObject == null) {
            Debug.LogError("Localization::UpdateLocalization >> Make sure the languageSelect dropdown is called \"LanguageSelect\"");
            CurrentLanguage = "English";
        } else {
            dropdownObject.options.Clear();
            foreach (var key in _localizationDictionary.Keys) {
                Dropdown.OptionData data = new Dropdown.OptionData(key);
                dropdownObject.options.Add(data);
            }

            CurrentLanguage = dropdownObject.options[PlayerPrefs.GetInt("Language")].text;
        }
        dropdownObject.value = PlayerPrefs.GetInt("Language");

        //        new List<MainMenu_Settings>(Resources.FindObjectsOfTypeAll<MainMenu_Settings>()).ForEach(i => i.gameObject.SetActive(false));

        UpdateLocalization();
    }
开发者ID:koenvandensteen,项目名称:PirateGambit,代码行数:44,代码来源:Localization.cs


示例19: CreateLocalizations

        private void CreateLocalizations(PropertyInfo propertyInfo, Dictionary dictionary)
        {
            IEnumerable<Culture> cultures = this.Storage.GetRepository<ICultureRepository>().All();

              foreach (Culture culture in cultures)
              {
            Localization localization = new Localization();

            localization.DictionaryId = dictionary.Id;
            localization.CultureId = culture.Id;

            string identity = propertyInfo.Name + culture.Code;
            string value = this.Request.Form[identity];

            localization.Value = value;
            this.Storage.GetRepository<ILocalizationRepository>().Create(localization);
              }

              this.Storage.Save();
        }
开发者ID:OlegDokuka,项目名称:Platformus,代码行数:20,代码来源:ControllerBase.cs


示例20: ExecuteQuery

        public void ExecuteQuery(SearchQuery searchQuery, Type resultType, Localization localization)
        {
            using (new Tracer(searchQuery, resultType, localization))
            {
                string searchIndexUrl = GetSearchIndexUrl(localization);
                NameValueCollection parameters = SetupParameters(searchQuery, localization);
                SearchResults results = ExecuteQuery(searchIndexUrl, parameters);
                if (results.HasError)
                {
                    Log.Error("Error executing Search Query on URL '{0}': {1}", results.QueryUrl ?? searchIndexUrl, results.ErrorDetail);
                }
                Log.Debug("Search Query '{0}' returned {1} results.", results.QueryText ?? results.QueryUrl, results.Total);

                searchQuery.Total = results.Total;
                searchQuery.HasMore = searchQuery.Start + searchQuery.PageSize <= results.Total;
                searchQuery.CurrentPage = ((searchQuery.Start - 1) / searchQuery.PageSize) + 1;

                foreach (SearchResult result in results.Items)
                {
                    searchQuery.Results.Add(MapResult(result, resultType, searchQuery.SearchItemView));
                }
            }
        }
开发者ID:RAJMITTAL,项目名称:dxa-modules,代码行数:23,代码来源:SI4TSearchProvider.cs



注:本文中的Localization类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Localizer类代码示例发布时间:2022-05-24
下一篇:
C# Locale类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap