Skip to content

Commit

Permalink
translation default culture disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
LazZiya committed Jul 27, 2020
1 parent d741972 commit 0163df8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
11 changes: 2 additions & 9 deletions XLocalizer/XLocalizer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,14 @@
<Authors>Ziya Mollamahmut</Authors>
<Company>Ziyad.info</Company>
<Description>
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.
</Description>
<Copyright>Ziyad.info</Copyright>
<PackageProjectUrl>http://docs.ziyad.info/XLocalizer</PackageProjectUrl>
<PackageIcon>icon.png</PackageIcon>
<PackageTags>asp.net,core,razor,mvc,localization,globalization,client side,validation,translation,autokeyadding</PackageTags>
<PackageReleaseNotes>
- 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
</PackageReleaseNotes>
<Version>1.0.0-preview2</Version>
Expand Down
7 changes: 4 additions & 3 deletions XLocalizer/XStringLocalizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<TResource>(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)
Expand Down

0 comments on commit 0163df8

Please sign in to comment.