Hi, Readers.
Today I saw a very interesting question on the Dynamics 365 Business Central Forum. In this post, I would like to to share and discuss it briefly, hoping to help more people.
Let’s look at the question.
How to Delete Windows Language – Dynamics 365 Business Central Forum Community Forum
I only want to choose 1-2 language like English & Chinese,how can i delete another language?
https://community.dynamics.com/business/f/dynamics-365-business-central-forum/484509/how-to-delete-windows-language
I can not found this table in sql server ..any way to do this? my version is BC210,local version.
To change the language of the user interface, go to the My Settings page.
Language: Changes the display language. This field appears only when there’s more than one language to choose from. For more information, see Change Basic Settings.
This page displays all available languages. (Windows Languages (535, List))
More details: Supported languages
Well, first of all, there are three main reasons why this is difficult to do.
1. The object Page ‘Windows Languages’ is not extensible.
2. Language field in User Settings (9204, StandardDialog) is not a real field.
3. Page ‘Windows Languages’ does not directly display the content of the table, but is inserted through code, so Security Filters is not available. More details: UsingSecurity Filters and SecurityFiltering Property
So how to do? It’s actually not too difficult😁. I will share a relatively simple way, if you have better suggestions, feel free to contact me.
In this solution, we need the following four steps.
1. Hide the standard LanguageName field
2. Create a new variable as the language id for the user to choose. In the TableRelation property, limit the records that the user can select.
2052|1033
3. When the user selects a new Language ID, modify the Language ID of SourceTable “User Settings”.
This will take effect when the user clicks OK. I mentioned this briefly when we discussed Allow user selection of Role Center (Profile) for each company (Multiple roles for one user) – Customization.
4. Because this new field is a variable, in order to make it not empty when the page is opened, let it display the current language.
More details: Windows Language ID and Global Language ID
Completed.
Let me do a test to see if it works.
Test Video: Because I didn’t install the language pack, I judge whether it takes effect according to the language of the Platform.
Looks great. Give it a try!!!😁
Source Code: Github
pageextension 50114 MyExtension extends "User Settings"
{
layout
{
modify(LanguageName)
{
Visible = false;
}
addafter(Region)
{
field(ZYLanguageID; ZYLanguageID)
{
Caption = 'ZY Language ID';
ApplicationArea = All;
TableRelation = "Windows Language"."Language ID" where("Language ID" = filter(2052 | 1033));
trigger OnValidate()
begin
Rec."Language ID" := ZYLanguageID;
end;
}
}
}
var
ZYLanguageID: Integer;
trigger OnOpenPage()
begin
ZYLanguageID := GlobalLanguage;
end;
}
Update 2023.04.20: I learned another simple method from my friend yesterday.
Just subscribe ‘OnOpenPageEvent’ of “Windows Languages” page.
Source Code:
codeunit 50114 MyCodeunit3
{
[EventSubscriber(ObjectType::Page, page::"Windows Languages", 'OnOpenPageEvent', '', false, false)]
local procedure OpenPageEvent(var Rec: Record "Windows Language")
begin
if Rec.IsTemporary then
Rec.SetFilter("Language ID", '2052|1033|1034');
end;
}
PS:
1. You can also consider using SessionSettings Data Type to do it.
More details: SessionSettings Data Type (A complex data type)
2. XLIFF translation files (Working with Translations)
END
Hope this will help.
Thanks for your reading.
ZHU
コメント