From 0163df867efd03e0687f7e44e94b77ebb75526d0 Mon Sep 17 00:00:00 2001 From: LazZiya Date: Mon, 27 Jul 2020 13:13:45 +0300 Subject: [PATCH] translation default culture disabled --- XLocalizer/XLocalizer.csproj | 11 ++--------- XLocalizer/XStringLocalizer.cs | 7 ++++--- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/XLocalizer/XLocalizer.csproj b/XLocalizer/XLocalizer.csproj index 3b88d0e..b26c720 100644 --- a/XLocalizer/XLocalizer.csproj +++ b/XLocalizer/XLocalizer.csproj @@ -7,21 +7,14 @@ Ziya Mollamahmut Ziyad.info - Save ~99% of development on localization of Asp.Net Core web applications. + XLocalizer package for localization of Asp.Net Core web applications, powered by online translation and auto resource creating. Ziyad.info http://docs.ziyad.info/XLocalizer icon.png asp.net,core,razor,mvc,localization,globalization,client side,validation,translation,autokeyadding - - Supports .net core 2.0, 2.1, 3.0, 3.1, 5.0 - - Built-in support for localization based on .resx, .xml - - DB based localization (required XLocalizer.DB) - - Auto online translation support - - Auto add missing keys to XML or DB - - Export resources from XML to .resx easily with built-in resource exporter - - IXResourceProvider interface to implement localizaton based on custom file types - - IXResourceExporter interface to implement custom exporters to export from custom file types to .resx + - Fix for translation issues with default culture Release notes: https://github.com/LazZiya/XLocalizer/releases 1.0.0-preview2 diff --git a/XLocalizer/XStringLocalizer.cs b/XLocalizer/XStringLocalizer.cs index e59d674..25c8d53 100644 --- a/XLocalizer/XStringLocalizer.cs +++ b/XLocalizer/XStringLocalizer.cs @@ -94,20 +94,21 @@ private LocalizedString GetLocalizedString(string name, params object[] argument if (!availableInCache) { + var culture = CultureInfo.CurrentCulture.Name; + // Option 2: Look in resource bool availableInSource = _provider.TryGetValue(name, out value); if (!availableInSource && _options.AutoTranslate) { - var culture = CultureInfo.CurrentCulture.Name; - if(_defaultCulture != culture) + if (_defaultCulture != culture) // Option 3: Online translate availableInTranslate = _translator.TryTranslate(_defaultCulture, culture, name, out value); } // add a resource if it is not available in source and auto add is enabled - if (!availableInSource && _options.AutoAddKeys) + if (!availableInSource && _options.AutoAddKeys && _defaultCulture != culture) { // Add a resource only if auto translate is off or if available in translation if (!_options.AutoTranslate || availableInTranslate)