Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add/Delete culture data #69

Open
abircan opened this issue Feb 28, 2020 · 6 comments
Open

Add/Delete culture data #69

abircan opened this issue Feb 28, 2020 · 6 comments

Comments

@abircan
Copy link

abircan commented Feb 28, 2020

I have two question.
In the production,

  1. What is the correct way to delete all your data for a culture?
  2. What is the right way to add new culture data? without importing csv, from the admin panel.
@abircan
Copy link
Author

abircan commented Mar 5, 2020

Hello @damienbod , are you still developing this project?

@damienbod
Copy link
Owner

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

@aliramadan8
Copy link

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

@abircan
Copy link
Author

abircan commented Mar 5, 2020

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(); 

@borahanarslan
Copy link

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 ?

@abircan
Copy link
Author

abircan commented Apr 18, 2020

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants