simpleidserver / SimpleIdServer

OpenID, OAuth 2.0, SCIM2.0, UMA2.0, FAPI, CIBA & OPENBANKING Framework for ASP.NET Core
https://simpleidserver.com/
Apache License 2.0
716 stars 94 forks source link

IdServer - Don't use the current language to store the translation of the configuration #670

Open simpleidserver opened 9 months ago

qq1176914912 commented 9 months ago

As you expected, I printed 'Thread' on the published server CurrentThread Current Culture TwoLetterISOLanguageName 'found that the server output result is en, while the value in my Translations table is zh. However, not all of them are zh, and some are still en. This is why the pop-up content mentioned earlier is not affected. I think you can imitate the method where the field is still en and modify other methods to solve this problem

This is the database content on my publishing server: image Starting from line 84, it will be automatically copied based on my system language. For example, when I publish the server, the value of en here is en, and my local value is zh, which is zh. Can you imitate the method here and modify other methods to ensure this effect and solve the problem I mentioned?

Another method is to modify the language of the publishing server to be the same as the database. I found that when I changed the server language to zh, after 84 lines in the database, the zh above 84 lines was still displayed as en, which caused the zh above 84 lines to be displayed normally, but the one below, which is en, to not be displayed. How did you assign values to the database and why is it different? (The databases used in this process are all from before and not from scratch), I tried to have the program recreate the library, I found that there seems to be no problem after recreating the library. Is there any problem with the process of assigning values to the database?Are there any values that are only assigned during table creation and not modified during subsequent operations.

simpleidserver commented 9 months ago

I have implemented the following changes in the master branch :

The language is no longer determined by the language of the user account used to run the service but by the Accept-Language HTTP HEADER. Please remember to update all records in the Translation table and set the language to en.

To support a new language, you can add a record to the Language table, duplicate the values present in the Translation table, and update the values accordingly.

qq1176914912 commented 8 months ago

I have implemented the following changes in the master branch :

  • The default language is now set to English.
  • The list of supported languages is stored in a Language table and displayed on the website.

The language is no longer determined by the language of the user account used to run the service but by the Accept-Language HTTP HEADER. Please remember to update all records in the Translation table and set the language to en.

To support a new language, you can add a record to the Language table, duplicate the values present in the Translation table, and update the values accordingly.

1、Following your method, I made the following changes in the database: image image When I started the project and accessed 5002, all the languages in the top right corner disappeared, but I could vaguely see two places: image Is there something else to configure, and changing the database isn't enough? 2、Assuming that the top right corner of 5002 is displayed correctly, I want to convert everything in the page to the language I need: image Your current project is not supported, because I see that some of your hints seem to be written dead in the code. 3、If you do support what I said in question 2, where should I save my converted content? What am I going to do?

simpleidserver commented 8 months ago

The Identity Server utilizes the translation and language tables to interpret certain metadata of the Backend entities, such as the Client name or the Configuration Property.

The majority of translations featured on the administration website are sourced from the Resources\Global.resx file. Unfortunately, this file is not complete, and all translations need to be relocated to this file. I have created ticket #693 for this purpose.

I have created a branch named "Ticket693," which illustrates how to update the project to accommodate the "French" language. I have implemented the following modifications:

https://github.com/simpleidserver/SimpleIdServer/commit/2fca56250cfde0b2847ed3577f4e1e9cf62eaf52

qq1176914912 commented 8 months ago

The Identity Server utilizes the translation and language tables to interpret certain metadata of the Backend entities, such as the Client name or the Configuration Property.

The majority of translations featured on the administration website are sourced from the Resources\Global.resx file. Unfortunately, this file is not complete, and all translations need to be relocated to this file. I have created ticket #693 for this purpose.

I have created a branch named "Ticket693," which illustrates how to update the project to accommodate the "French" language. I have implemented the following modifications:

  • Add a new resource file Global.fr.resx.
  • Edit the Program.cs file of the administration website and include fr in the list of supported languages.
  • Edit the IdServerConfiguration.cs file of the Identity Server to introduce a new language along with its corresponding translation.

2fca562

Thank you for your hard work and look forward to the realization of this function.

qq1176914912 commented 8 months ago

The Identity Server utilizes the translation and language tables to interpret certain metadata of the Backend entities, such as the Client name or the Configuration Property.

The majority of translations featured on the administration website are sourced from the Resources\Global.resx file. Unfortunately, this file is not complete, and all translations need to be relocated to this file. I have created ticket #693 for this purpose.

I have created a branch named "Ticket693," which illustrates how to update the project to accommodate the "French" language. I have implemented the following modifications:

  • Add a new resource file Global.fr.resx.
  • Edit the Program.cs file of the administration website and include fr in the list of supported languages.
  • Edit the IdServerConfiguration.cs file of the Identity Server to introduce a new language along with its corresponding translation.

2fca562

1 1、I followed your method and first copied your "Global.fr.resx" in "Resources" and changed the name to: Global.zh.resx: image Then go to "Global.zh.Designer.cs" and replace "Global___Copier" with "Global_zh" (because it is a copied file, it conflicts with the original file) : image And I have translated some of the content: image 2、Then, in "SimpleIdServer. IdServer. Their Startup" of the Program. The cs in the following changes: image 3、Then, in "SimpleIdServer. IdServer. Startup" "IdServerConfiguration. Cs" has carried on the following changes: image 4、After starting the project, the following problems are found: The project is started by default in Chinese for the first time, but there is only Chinese option in the language box, and the other options are blank. image When I click on the first blank (which should be the English option), the language box appears in all three languages: image When I clicked "french" again, the last option in the language box went blank: image When I clicked on the last blank again, just like at the beginning, the first two became blank again.

Another question is that the "SetDefaultCulture" we configured in "Program.cs" is "en". Why did the language box choose "Chinese" I added instead of English by default when I first visited it?

2 So far, I have found that the translation content is not comprehensive, such as the following: image image image What do I do if I want to translate the entire content of the web (not just what is in the screenshot)? image If I want to translate the entire content of the web (not just what is in the screenshot), do I have to replace all the text with @Global.xxxx?

simpleidserver commented 8 months ago

Languages are not fully translated due to missing translations. For each language, a translation must be provided.

For example :

LanguageBuilder.Build(Language.Default).AddDescription("English").AddDescription("French", "fr").AddDescription("Chinese", "zh").Build(),
LanguageBuilder.Build("fr").AddDescription("Français", "fr").AddDescription("Anglais", "en").AddDescription("Chinois", "zh").Build(),
LanguageBuilder.Build("zh").AddDescription("<CHINESE>", "zh").AddDescription("<ENGLISH>", "en").AddDescription("<FRENCH>", "fr").Build()

Normally, the entire content of the website should be translated in the Global.resx. However, as explained in the previous conversation, there are translations present in the razor pages that need to be moved to the Global.resx file (please refer to ticket #693). We will address this issue in the upcoming release (4.0.8). Before proceeding, we need to complete the refactoring of the "Credential Issuer."

qq1176914912 commented 7 months ago

Languages are not fully translated due to missing translations. For each language, a translation must be provided.

For example :

LanguageBuilder.Build(Language.Default).AddDescription("English").AddDescription("French", "fr").AddDescription("Chinese", "zh").Build(),
LanguageBuilder.Build("fr").AddDescription("Français", "fr").AddDescription("Anglais", "en").AddDescription("Chinois", "zh").Build(),
LanguageBuilder.Build("zh").AddDescription("<CHINESE>", "zh").AddDescription("<ENGLISH>", "en").AddDescription("<FRENCH>", "fr").Build()

Normally, the entire content of the website should be translated in the Global.resx. However, as explained in the previous conversation, there are translations present in the razor pages that need to be moved to the Global.resx file (please refer to ticket #693). We will address this issue in the upcoming release (4.0.8). Before proceeding, we need to complete the refactoring of the "Credential Issuer."

I found a branch on your branch called "Ticket693_Move", I downloaded it and ran it, I found that when I changed the "Languages" in "IdServerConfiguration.cs" to what you said: image 5002 page appears with two identical languages: image I also tried to branch "Ticket693" and also modify "IdServerConfiguration.cs" and his display results are correct: image In addition to the translation content of the two branches, is the code different?

simpleidserver commented 7 months ago

Hello :)

The modifications made in the Ticket693_Move branch have been merged into the master branch. The translations of all Identity Server NuGet packages have been moved to the resources files, and I haven't made any other changes.

Even though the documentation has not been published yet, you can find some information here: https://github.com/simpleidserver/SimpleIdServer/blob/master/website/docs/developer/addlanguage.md

qq1176914912 commented 7 months ago

Hello :)

The modifications made in the Ticket693_Move branch have been merged into the master branch. The translations of all Identity Server NuGet packages have been moved to the resources files, and I haven't made any other changes.

Even though the documentation has not been published yet, you can find some information here: https://github.com/simpleidserver/SimpleIdServer/blob/master/website/docs/developer/addlanguage.md

Hello, thank you for your reply. 1、I found a problem with your tutorial, if written as you said: image In the list of languages, there are two languages with the same meaning, but they are written differently for different languages: image The correct thing to show in both languages is to write:

LanguageBuilder.Build(Language.Default).AddDescription("English", "en").AddDescription("Anglais", "fr").Build(), LanguageBuilder.Build("fr").AddDescription("Français", "fr").AddDescription("French", "en").Build()

The first line should be written in a different language's version of English, rather than in another language, as follows: image 2、I retested the master version, but when I clicked on 'French', the page didn't translate and 'English' was selected back by default(Branch Ticket693 does not have this problem): https://github.com/simpleidserver/SimpleIdServer/assets/79817742/95b66f94-60e1-4df9-9cce-019a0e6e35b2 "SimpleIdServer. IdServer. I have been in the Website" projects has increased the following (just the file name is different, the content of did not change, I am a direct copy of a copy) : image

3、Language not compatible with older versions: Using an older database does not add a new language to the database, you need to add it manually, or use a new database 4、Changing the contents of the 'Languages' in 'IdServerConfiguration.cs' also does not change the contents of the database, and can only be changed manually or regenerated automatically. It is recommended that you use a new database for testing, if you are unable to test for problems, it may be because your old database is correct.

simpleidserver commented 7 months ago

I've made some changes in the master branch. The languages were not translated correctly, and there was a small issue in the documentation. Now, when you start the SimpleIdServer project, the language will be automatically provisioned into the database, and there is no need to execute a custom SQL SCRIPT.

qq1176914912 commented 7 months ago

I've made some changes in the master branch. The languages were not translated correctly, and there was a small issue in the documentation. Now, when you start the SimpleIdServer project, the language will be automatically provisioned into the database, and there is no need to execute a custom SQL SCRIPT.

1、Thanks for your changes, the test found that the issue was resolved, but some translations were not included in the global variables: Authentication methods: image Extract: image 2、In "Clients", when the client "Name" has a value, the value will disappear after switching languages: https://github.com/simpleidserver/SimpleIdServer/assets/79817742/871e1a15-748b-4bec-ba9f-d29455bcca43 And the form does not display the name after adding the client: image

simpleidserver commented 7 months ago

It is normal that these translations are not present in the Global resource file because they are stored in the dbo.Translations table. You can execute the following SQL query to retrieve them:

SELECT [Record].[Name], [Translations].*  FROM [IdServer].[dbo].[ConfigurationDefinitionRecord] [Record]
INNER JOIN [dbo].ConfigurationDefinitionRecordTranslation [Tr] ON [Tr].[ConfigurationDefinitionRecordId] = [Record].[Id]
INNER JOIN [dbo].[Translations] [Translations] ON [Translations].[Id] = [Tr].[TranslationsId]
qq1176914912 commented 7 months ago

It is normal that these translations are not present in the Global resource file because they are stored in the dbo.Translations table. You can execute the following SQL query to retrieve them:

SELECT [Record].[Name], [Translations].*  FROM [IdServer].[dbo].[ConfigurationDefinitionRecord] [Record]
INNER JOIN [dbo].ConfigurationDefinitionRecordTranslation [Tr] ON [Tr].[ConfigurationDefinitionRecordId] = [Record].[Id]
INNER JOIN [dbo].[Translations] [Translations] ON [Translations].[Id] = [Tr].[TranslationsId]

1、Ok, another problem is that the "client name" disappears after switching languages. Serial number 2 in here https://github.com/simpleidserver/SimpleIdServer/issues/670#issuecomment-1953365143 2、New problem: When adding "Children" after adding a group, delete the newly added "Children" immediately after adding the group successfully, resulting in deletion failure. 5002 reports an error: image The video operation is as follows: https://github.com/simpleidserver/SimpleIdServer/assets/79817742/e878cb67-1ae1-476c-84c8-7eda656664f0

qq1176914912 commented 7 months ago

It is normal that these translations are not present in the Global resource file because they are stored in the dbo.Translations table. You can execute the following SQL query to retrieve them:

SELECT [Record].[Name], [Translations].*  FROM [IdServer].[dbo].[ConfigurationDefinitionRecord] [Record]
INNER JOIN [dbo].ConfigurationDefinitionRecordTranslation [Tr] ON [Tr].[ConfigurationDefinitionRecordId] = [Record].[Id]
INNER JOIN [dbo].[Translations] [Translations] ON [Translations].[Id] = [Tr].[TranslationsId]

does exist in the database, but the problem is that the database structure seems to be one-to-one to me: image Because of compatibility with multiple languages, this relationship changes to one-to-many, and if I simply change the language of the "Translations" table to the language I need, it will only be compatible with the language I need, and the other languages will not be compatible.

simpleidserver commented 7 months ago

Client name disappearance:

It is normal for the client name to disappear when the language is changed because this property is translatable. According to the RFC (https://openid.net/specs/openid-connect-registration-1_0.html#LanguagesAndScripts), the following client properties must be translatable:

You can update the client_name in the Client Details screen.

Exception : The exception "One or more errors occured" has been fixed in the master branch. There was a small issue in the GroupReducer class.

Database structure :

The database structure is MANY to MANY.

image

qq1176914912 commented 7 months ago

Client name disappearance:

It is normal for the client name to disappear when the language is changed because this property is translatable. According to the RFC (https://openid.net/specs/openid-connect-registration-1_0.html#LanguagesAndScripts), the following client properties must be translatable:

  • client_name
  • tos_uri
  • policy_uri
  • logo_uri
  • client_uri

You can update the client_name in the Client Details screen.

Exception : The exception "One or more errors occured" has been fixed in the master branch. There was a small issue in the GroupReducer class.

Database structure :

The database structure is MANY to MANY.

image

Client name disappearance: Yes, when I switched languages, after I updated "client_name" there were Translations for that language in the database table "Translations", of course for clients that were created before the translation work was done. I tested the creation of the client after switching languages, and I found that even though I changed languages, the language added to the "Translations" table for the name of the client was still en, not the language I switched, so do you need to change it here, instead of the default always being en, it is bound to the current language: The client is created assuming that the current Language is x, so when the client is created, the "language" column in the "Translations" table should be x, not en, which should fix the problem: image If you make this change, the client name should not be blank after the creation here is successful. I have an idea. What do you think about this? When the client is created, all currently existing translation types are added to the "Translations" table at the same time (en, fr.....) As for the translated content, the value can be the same as the value of the client created in the current language, which can solve the problem of empty, at least will not let the user wonder that the value I created before disappeared (I think that the client name will not be deliberately translated), of course, if the user needs to change, then manually update can be. Database structure : Sorry to ignore this, originally "ConfigurationDefinitionRecordId" can be repeated, so that you can correspond to more than one language. image

qq1176914912 commented 7 months ago

I noticed that the following figure does not change the translation after switching languages, but based on the first load, so I changed your code: image The changes are as follows: image

private static ProofOfPossession GetProofOfPossession()
 {
     return new ProofOfPossession { Name = "MTLS", Description = Global.Mtls };
 }
// Define a property to hold the ProofOfPossession
private static ProofOfPossession MTLs => GetProofOfPossession();
simpleidserver commented 7 months ago

The client name is incorrect.

The issue has been resolved in the master branch. When a client is added, its name will now be stored in the translation table with the correct language.

MTLS is not translated.

The issue has been addressed in the master branch; however, Mtls and Dpop are not defined as static variables.