Giter Site home page Giter Site logo

Comments (6)

aliramadan8 avatar aliramadan8 commented on June 13, 2024 1

Hi , i found it much faster to do it from DB side so i created a stored procedure and i just call it from my code ,my procedure below add new culture to the site , simply copying all existing word in new language ,but no translation

Create procedure  [dbo].[usp_syCreateSiteCulture] 
(
@NewCulture nvarchar(15) -- new culture to be used ex 'ar-eg'

)
As
Begin


INSERT INTO [dbo].[tblLocalizationRecords]
           ([ResourceId]
           ,[ResourceKey]
           ,[Value]
           ,[LocalizationCulture]
           ,[UpdatedTimestamp]
           ,[FriendlyName])

  	SELECT Distinct  
       [ResourceId]
      ,[ResourceKey]
      ,[Value]
      ,@NewCulture
      ,GetDate()
      ,[FriendlyName]
  FROM [dbo].[tblLocalizationRecords] Orgi
  Where LocalizationCulture = 'en-US'

  and NOT EXISTS (Select * from tblLocalizationRecords tb
          where  tb.[ResourceId] = orgi.[ResourceId]
		    and  tb.[ResourceKey] = orgi.ResourceKey
			and  [LocalizationCulture] = @NewCulture )
End

from aspnetcorelocalization.

abircan avatar abircan commented on June 13, 2024 1

Thank you @damienbod

I used StringExtendedLocalizerFactory in my solution.

 var defaultLang = stringExtendedLocalizerFactory.GetLocalizationData(DateTime.MinValue, "tr-tr", $"Create for {Lang.Name} translation") as List<LocalizationRecord>;
            List<LocalizationRecord> newRecords = new List<LocalizationRecord>();
            foreach (var item in defaultLang)
            {
                LocalizationRecord r = new LocalizationRecord
                {
                    Key = item.Key,
                    LocalizationCulture = Lang.Code,
                    ResourceKey = item.ResourceKey,
                    Text = item.Key
                };
                newRecords.Add(r);
            }
            stringExtendedLocalizerFactory.AddNewLocalizationData(newRecords, "Copy from default language");
  stringExtendedLocalizerFactory.ResetCache(); 

from aspnetcorelocalization.

abircan avatar abircan commented on June 13, 2024 1

@borahanarslan şu an production da ASP .NET Core 3.1 projesi ile kullanıyorum.

I am using AspNetCoreLocalization with ASP .NET Core 3.1 project.

from aspnetcorelocalization.

abircan avatar abircan commented on June 13, 2024

Hello @damienbod , are you still developing this project?

from aspnetcorelocalization.

damienbod avatar damienbod commented on June 13, 2024

Sorry for the slow answer, busy at the day job

Hi @abircan yes, you could just use EF Core with a new context, or use the existing to create your queries to delete, add in anyway you want.

Greetings Damien

from aspnetcorelocalization.

borahanarslan avatar borahanarslan commented on June 13, 2024

Thank you @damienbod

I used StringExtendedLocalizerFactory in my solution.

 var defaultLang = stringExtendedLocalizerFactory.GetLocalizationData(DateTime.MinValue, "tr-tr", $"Create for {Lang.Name} translation") as List<LocalizationRecord>;
            List<LocalizationRecord> newRecords = new List<LocalizationRecord>();
            foreach (var item in defaultLang)
            {
                LocalizationRecord r = new LocalizationRecord
                {
                    Key = item.Key,
                    LocalizationCulture = Lang.Code,
                    ResourceKey = item.ResourceKey,
                    Text = item.Key
                };
                newRecords.Add(r);
            }
            stringExtendedLocalizerFactory.AddNewLocalizationData(newRecords, "Copy from default language");
  stringExtendedLocalizerFactory.ResetCache(); 

Hocam 3.1 sürümünde denedinizmi çalışıyormu ?

from aspnetcorelocalization.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.