mirror of
https://github.com/IRPTeam/IRP.git
synced 2025-09-16 08:56:27 +02:00
Fixing localization mechanisms (#2832)
* Fixing localization mechanisms * fix bug
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
|
||||
Procedure PresentationGetProcessing(Data, Presentation, StandardProcessing)
|
||||
StandardProcessing = False;
|
||||
Presentation = String(Data["Description_" + LocalizationReuse.UserLanguageCode()]);
|
||||
Presentation = String(Data["Description_" + LocalizationReuse.GetLocalizationCode()]);
|
||||
EndProcedure
|
||||
|
||||
Procedure PresentationFieldsGetProcessing(Fields, StandardProcessing)
|
||||
@@ -107,7 +107,9 @@ Function GetExecutionFlowchart(ProcessRef) Export
|
||||
Query.SetParameter("Ref", ProcessRef);
|
||||
Query.SetParameter("EmptyID", New UUID("00000000-0000-0000-0000-000000000000"));
|
||||
|
||||
Query.Text = StrReplace(Query.Text, "Description_en", "Description_" + LocalizationReuse.UserLanguageCode());
|
||||
LocalizationEvents.ReplaceDescriptionLocalizationPrefix(Query.Text, "Stages");
|
||||
LocalizationEvents.ReplaceDescriptionLocalizationPrefix(Query.Text, "Tasks");
|
||||
|
||||
QuerySelection = Query.Execute().Select();
|
||||
|
||||
CurrentStage = Undefined;
|
||||
|
@@ -317,7 +317,7 @@ Procedure FillDescriptionByTemplateAtClient(CommandName)
|
||||
ElsIf StrStartsWith(CommandName, "CommandFillByTemplate_ForeignDescription") Then
|
||||
FillDescriptionByTemplateAtServer("ForeignFullDescription", "ItemForeignFullDescriptionTemplate");
|
||||
Else
|
||||
Raise StrTemplate(R().ItemFormUnknownCommand, CommandName);
|
||||
Raise StrTemplate(R().ItemFormUnknownCommand, CommandName);
|
||||
EndIf;
|
||||
EndProcedure
|
||||
|
||||
|
@@ -97,9 +97,16 @@ EndProcedure
|
||||
&AtServer
|
||||
Procedure FillExistsLangs()
|
||||
|
||||
For Each Lang In Metadata.Languages Do
|
||||
InterfaceLocalizations = LocalizationReuse.GetInterfaceLocalizations();
|
||||
For Each Lang In InterfaceLocalizations Do
|
||||
//@skip-check typed-value-adding-to-untyped-collection
|
||||
Items.InterfaceLocalizationCode.ChoiceList.Add(Lang.LanguageCode, Lang.Synonym);
|
||||
EndDo;
|
||||
|
||||
DataLocalizations = LocalizationReuse.GetDataLocalizations();
|
||||
For Each Lang In DataLocalizations Do
|
||||
//@skip-check typed-value-adding-to-untyped-collection
|
||||
Items.LocalizationCode.ChoiceList.Add(Lower(Lang.LanguageCode), Lang.Synonym);
|
||||
Items.InterfaceLocalizationCode.ChoiceList.Add(Lower(Lang.LanguageCode), Lang.Synonym);
|
||||
EndDo;
|
||||
|
||||
EndProcedure
|
||||
|
@@ -6,12 +6,8 @@ EndProcedure
|
||||
|
||||
Procedure PresentationGetProcessing(Data, Presentation, StandardProcessing)
|
||||
StandardProcessing = False;
|
||||
InterfaceLocalizationCode = LocalizationReuse.GetSessionParameter("InterfaceLocalizationCode");
|
||||
UserLangPresentation = Data.Ref["Description_" + InterfaceLocalizationCode];
|
||||
|
||||
Presentation = ?(ValueIsFilled(UserLangPresentation),
|
||||
UserLangPresentation,
|
||||
Data.Ref.Description_en);
|
||||
InterfaceLocalizationCode = LocalizationReuse.GetInterfaceLocalizationCode();
|
||||
Presentation = LocalizationServer.RefDescription(Data.Ref, InterfaceLocalizationCode);
|
||||
EndProcedure
|
||||
|
||||
Procedure UpdatePredefinedNames(PredefinedDataName) Export
|
||||
|
@@ -1222,11 +1222,6 @@ Function SearchByItemAndItemKeysDescriptions_WithKey(GetItemAndItemKeysInputTabl
|
||||
| ELSE MainData.ItemKey = Images.ItemKey
|
||||
| END";
|
||||
|
||||
DescriptionLocal = "Description_" + LocalizationReuse.GetLocalizationCode();
|
||||
If Not DescriptionLocal = "Description_en" Then
|
||||
Query.Text = StrReplace(Query.Text, "Description_en", DescriptionLocal);
|
||||
EndIf;
|
||||
|
||||
Query.SetParameter("ItemAndItemKeysDescriptions", GetItemAndItemKeysInputTable);
|
||||
QueryExecution = Query.Execute();
|
||||
QueryUnload = QueryExecution.Unload();
|
||||
@@ -1283,10 +1278,7 @@ Function SearchItemByString(ItemString) Export
|
||||
| NOT Items.DeletionMark
|
||||
| AND Items.Description_en = &Item";
|
||||
|
||||
DescriptionLocal = "Description_" + LocalizationReuse.GetLocalizationCode();
|
||||
If Not DescriptionLocal = "Description_en" Then
|
||||
Query.Text = StrReplace(Query.Text, "Description_en", DescriptionLocal);
|
||||
EndIf;
|
||||
LocalizationEvents.ReplaceDescriptionLocalizationPrefix(Query.Text, "Items");
|
||||
|
||||
Return Query.Execute().Unload().UnloadColumn(0);
|
||||
|
||||
@@ -1349,10 +1341,7 @@ Function SearchItemKeyByString(ItemKeyString, ItemRef) Export
|
||||
| &Item = VALUE(Catalog.Items.EmptyRef)
|
||||
| OR tmpRefs.Ref.Item = &Item";
|
||||
|
||||
DescriptionLocal = "Description_" + LocalizationReuse.GetLocalizationCode();
|
||||
If Not DescriptionLocal = "Description_en" Then
|
||||
Query.Text = StrReplace(Query.Text, "Description_en", DescriptionLocal);
|
||||
EndIf;
|
||||
LocalizationEvents.ReplaceDescriptionLocalizationPrefix(Query.Text, "ItemKeys");
|
||||
|
||||
Return Query.Execute().Unload().UnloadColumn(0);
|
||||
|
||||
|
@@ -10,7 +10,7 @@
|
||||
Function R(LangCode = "") Export
|
||||
|
||||
If IsBlankString(LangCode) Then
|
||||
LangCode = String(LocalizationReuse.GetSessionParameter("InterfaceLocalizationCode"));
|
||||
LangCode = LocalizationReuse.GetInterfaceLocalizationCode();
|
||||
EndIf;
|
||||
Return LocalizationReuse.Strings(LangCode);
|
||||
EndFunction
|
||||
|
@@ -229,14 +229,14 @@ Procedure GetCatalogPresentation(Source, Data, Presentation, StandardProcessing)
|
||||
ElsIf SourceType = Type("CatalogManager.PriceKeys") Then
|
||||
Presentation = LocalizationReuse.CatalogDescriptionWithAddAttributes(Data.Ref);
|
||||
If IsBlankString(Presentation) Then
|
||||
Presentation = StrTemplate(R().Error_005, LocalizationReuse.UserLanguageCode());
|
||||
Presentation = StrTemplate(R().Error_005, LocalizationReuse.GetInterfaceLocalizationCode());
|
||||
EndIf;
|
||||
ElsIf Data.Property("Description") Then
|
||||
Presentation = String(Data.Description);
|
||||
ElsIf Data.Property("FullDescription") And ValueIsFilled(Data.FullDescription) Then
|
||||
Presentation = String(Data.FullDescription);
|
||||
Else
|
||||
Presentation = String(Data["Description_" + LocalizationReuse.UserLanguageCode()]);
|
||||
Presentation = String(Data["Description_" + LocalizationReuse.GetLocalizationCode()]);
|
||||
If Presentation = "" Then
|
||||
For Each KeyData In Data Do
|
||||
If KeyData.Value = "" Then
|
||||
@@ -247,7 +247,7 @@ Procedure GetCatalogPresentation(Source, Data, Presentation, StandardProcessing)
|
||||
EndDo;
|
||||
|
||||
If Presentation = "" Then
|
||||
Presentation = StrTemplate(R().Error_002, LocalizationReuse.UserLanguageCode());
|
||||
Presentation = StrTemplate(R().Error_002, LocalizationReuse.GetInterfaceLocalizationCode());
|
||||
EndIf;
|
||||
EndIf;
|
||||
EndIf;
|
||||
|
@@ -47,29 +47,18 @@ Function AllDescription(AddInfo = Undefined) Export
|
||||
Return LocalizationServer.AllDescription(AddInfo);
|
||||
EndFunction
|
||||
|
||||
// Use multi language.
|
||||
// Use multi language for data.
|
||||
//
|
||||
// Parameters:
|
||||
// MetadataFullName - String - Metadata full name
|
||||
// AddInfo - Undefined, Structure - Add info
|
||||
//
|
||||
// Returns:
|
||||
// Boolean - Use multi language
|
||||
// Boolean - Use multi language for data
|
||||
Function UseMultiLanguage(Val MetadataFullName, AddInfo = Undefined) Export
|
||||
Return LocalizationServer.UseMultiLanguage(MetadataFullName, , AddInfo);
|
||||
EndFunction
|
||||
|
||||
// Get localization code.
|
||||
//
|
||||
// Parameters:
|
||||
// AddInfo - Undefined, Structure - Add info
|
||||
//
|
||||
// Returns:
|
||||
// String - Get localization code
|
||||
Function GetLocalizationCode(AddInfo = Undefined) Export
|
||||
Return LocalizationServer.GetLocalizationCode(AddInfo);
|
||||
EndFunction
|
||||
|
||||
// Fields list for descriptions.
|
||||
//
|
||||
// Parameters:
|
||||
@@ -81,16 +70,34 @@ Function FieldsListForDescriptions(Val SourceType) Export
|
||||
Return LocalizationServer.FieldsListForDescriptions(String(SourceType));
|
||||
EndFunction
|
||||
|
||||
// User language code.
|
||||
// Get localization code.
|
||||
//
|
||||
// Parameters:
|
||||
// AddInfo - Undefined, Structure - Add info
|
||||
//
|
||||
// Returns:
|
||||
// String - Get localization code
|
||||
Function GetLocalizationCode(AddInfo = Undefined) Export
|
||||
Return LocalizationServer.GetLocalizationCode(AddInfo);
|
||||
EndFunction
|
||||
|
||||
// Get interface localization code.
|
||||
//
|
||||
// Parameters:
|
||||
// AddInfo - Undefined, Structure - Add info
|
||||
//
|
||||
// Returns:
|
||||
// String - Get interface localization code
|
||||
Function GetInterfaceLocalizationCode(AddInfo = Undefined) Export
|
||||
Return LocalizationServer.GetInterfaceLocalizationCode(AddInfo);
|
||||
EndFunction
|
||||
|
||||
// NOTUSE. User language code.
|
||||
//
|
||||
// Returns:
|
||||
// String - User language code
|
||||
Function UserLanguageCode() Export
|
||||
LocalizationCode = "en";
|
||||
If Not IsBlankString(SessionParameters.LocalizationCode) Then
|
||||
LocalizationCode = SessionParameters.LocalizationCode;
|
||||
EndIf;
|
||||
Return LocalizationCode;
|
||||
Return GetLocalizationCode();
|
||||
EndFunction
|
||||
|
||||
// Get session parameter.
|
||||
@@ -201,4 +208,59 @@ Function ISO639() Export
|
||||
Str.Insert("id", "ind");
|
||||
Str.Insert("fa", "per");
|
||||
Return Str;
|
||||
EndFunction
|
||||
EndFunction
|
||||
|
||||
// Get interface localizations.
|
||||
//
|
||||
// Returns:
|
||||
// Array of Structure:
|
||||
// * LanguageCode - String - Language code
|
||||
// * Synonym - String - Language synonym
|
||||
Function GetInterfaceLocalizations() Export
|
||||
|
||||
InterfaceLocalizations = New Array; // Array of Structure
|
||||
|
||||
Languages = MetadataLanguages();
|
||||
For Each LangKeyValue In Languages Do
|
||||
Language = New Structure;
|
||||
Language.Insert("LanguageCode", Lower(LangKeyValue.Key));
|
||||
Language.Insert("Synonym", LangKeyValue.Value);
|
||||
InterfaceLocalizations.Add(Language);
|
||||
EndDo;
|
||||
|
||||
Return InterfaceLocalizations;
|
||||
|
||||
EndFunction
|
||||
|
||||
// Get data localizations.
|
||||
//
|
||||
// Returns:
|
||||
// Array of Structure:
|
||||
// * LanguageCode - String - Language code
|
||||
// * Synonym - String - Language synonym
|
||||
Function GetDataLocalizations() Export
|
||||
|
||||
DataLocalizations = New Array; // Array of Structure
|
||||
|
||||
InterfaceLocalizations = GetInterfaceLocalizations();
|
||||
LocalizationsMap = New Map;
|
||||
For Each Lang In InterfaceLocalizations Do
|
||||
LocalizationsMap.Insert(Lang.LanguageCode, Lang);
|
||||
EndDo;
|
||||
|
||||
For Each CommonAttribute In Metadata.CommonAttributes Do
|
||||
If StrStartsWith(CommonAttribute.Name, "Description_") Then
|
||||
LanguageCode = Lower(StrReplace(CommonAttribute.Name, "Description_", ""));
|
||||
Lang = LocalizationsMap.Get(LanguageCode);
|
||||
If Lang <> Undefined Then
|
||||
Language = New Structure;
|
||||
Language.Insert("LanguageCode", Lang.LanguageCode);
|
||||
Language.Insert("Synonym", Lang.Synonym);
|
||||
DataLocalizations.Add(Language);
|
||||
EndIf;
|
||||
EndIf;
|
||||
EndDo;
|
||||
|
||||
Return DataLocalizations;
|
||||
|
||||
EndFunction
|
@@ -73,8 +73,10 @@ EndFunction
|
||||
// Returns:
|
||||
// String - Catalog description
|
||||
Function CatalogDescription(Val Ref, Val LangCode = "", AddInfo = Undefined) Export
|
||||
LangCode = ?(ValueIsFilled(LangCode), LangCode, LocalizationReuse.GetLocalizationCode());
|
||||
Presentation = "";
|
||||
|
||||
LangCode = ?(ValueIsFilled(LangCode), LangCode, LocalizationReuse.GetLocalizationCode());
|
||||
|
||||
TypeOfRef = TypeOf(Ref);
|
||||
If TypeOfRef = Type("String") Or TypeOfRef = Type("Date") Or TypeOfRef = Type("Number") Then
|
||||
Presentation = String(Ref);
|
||||
@@ -89,6 +91,7 @@ Function CatalogDescription(Val Ref, Val LangCode = "", AddInfo = Undefined) Exp
|
||||
EndIf;
|
||||
|
||||
Return Presentation;
|
||||
|
||||
EndFunction
|
||||
|
||||
// Catalog description with additional attributes.
|
||||
@@ -103,7 +106,9 @@ EndFunction
|
||||
Function CatalogDescriptionWithAddAttributes(Val Ref, Val LangCode = "", AddInfo = Undefined) Export
|
||||
|
||||
Presentation = "";
|
||||
LangCode = ?(ValueIsFilled(LangCode), LangCode, LocalizationReuse.UserLanguageCode());
|
||||
|
||||
LangCode = ?(ValueIsFilled(LangCode), LangCode, LocalizationReuse.GetLocalizationCode());
|
||||
|
||||
UsersL = New Array(); // Array Of String
|
||||
For Each AddAttribute In Ref.AddAttributes Do
|
||||
If StrSplit(Ref.Metadata().FullName(), ".")[0] = "Catalog" Then
|
||||
@@ -123,9 +128,47 @@ Function CatalogDescriptionWithAddAttributes(Val Ref, Val LangCode = "", AddInfo
|
||||
Presentation = CatalogDescription(Ref.Item, LangCode, AddInfo);
|
||||
EndIf;
|
||||
EndIf;
|
||||
|
||||
Return Presentation;
|
||||
EndFunction
|
||||
|
||||
// Ref description.
|
||||
//
|
||||
// Parameters:
|
||||
// Ref - AnyRef - Ref
|
||||
// LangCode - String - Lang code
|
||||
// AddInfo - Undefined - Add info
|
||||
//
|
||||
// Returns:
|
||||
// String - Ref description
|
||||
Function RefDescription(Val Ref, Val LangCode = "", AddInfo = Undefined) Export
|
||||
|
||||
LangCode = ?(ValueIsFilled(LangCode), LangCode, LocalizationReuse.GetLocalizationCode());
|
||||
|
||||
TypeOfRef = TypeOf(Ref);
|
||||
If TypeOfRef = Type("String") Or TypeOfRef = Type("Date") Or TypeOfRef = Type("Number") Then
|
||||
Return String(Ref);
|
||||
EndIf;
|
||||
|
||||
If Not UseMultiLanguage(Ref.Metadata().FullName(), "", AddInfo) Then
|
||||
Return String(Ref);
|
||||
EndIf;
|
||||
|
||||
Presentation = "";
|
||||
If UseMultiLanguage(Ref.Metadata().FullName(), LangCode, AddInfo) Then
|
||||
Presentation = String(Ref["Description_" + LangCode]);
|
||||
Else
|
||||
Return String(Ref["Description_en"]);
|
||||
EndIf;
|
||||
|
||||
If IsBlankString(Presentation) Then
|
||||
Presentation = String(Ref["Description_en"]);
|
||||
EndIf;
|
||||
|
||||
Return Presentation;
|
||||
|
||||
EndFunction
|
||||
|
||||
// All description.
|
||||
//
|
||||
// Parameters:
|
||||
@@ -143,7 +186,7 @@ Function AllDescription(AddInfo = Undefined) Export
|
||||
Return Array;
|
||||
EndFunction
|
||||
|
||||
// Use multi language.
|
||||
// Use multi language for data.
|
||||
//
|
||||
// Parameters:
|
||||
// MetadataFullName - String - Metadata full name
|
||||
@@ -153,11 +196,11 @@ EndFunction
|
||||
// Returns:
|
||||
// Boolean - Use multi language
|
||||
Function UseMultiLanguage(Val MetadataFullName, Val LangCode = "", AddInfo = Undefined) Export
|
||||
LangCode = ?(ValueIsFilled(LangCode), LangCode, LocalizationReuse.UserLanguageCode());
|
||||
LangCode = ?(ValueIsFilled(LangCode), LangCode, LocalizationReuse.GetLocalizationCode());
|
||||
|
||||
MetadataFullName = StrReplace(MetadataFullName, "Manager.", ".");
|
||||
MetadataObject = Metadata.FindByFullName(MetadataFullName);
|
||||
MetadataObject = Metadata.FindByFullName(MetadataFullName); // MetadataObject
|
||||
DescriptionAttr = Metadata.CommonAttributes["Description_" + LangCode];
|
||||
//@skip-check invocation-parameter-type-intersect
|
||||
Content = DescriptionAttr.Content.Find(MetadataObject);
|
||||
|
||||
If Not Content = Undefined Then
|
||||
@@ -179,7 +222,26 @@ EndFunction
|
||||
// Returns:
|
||||
// String - Get localization code
|
||||
Function GetLocalizationCode(AddInfo = Undefined) Export
|
||||
Return TrimAll(SessionParameters.LocalizationCode);
|
||||
LangCode = "en";
|
||||
If Not IsBlankString(SessionParameters.LocalizationCode) Then
|
||||
LangCode = TrimAll(SessionParameters.LocalizationCode);
|
||||
EndIf;
|
||||
Return LangCode;
|
||||
EndFunction
|
||||
|
||||
// Get interface localization code.
|
||||
//
|
||||
// Parameters:
|
||||
// AddInfo - Undefined - Add info
|
||||
//
|
||||
// Returns:
|
||||
// String - Get interface localization code
|
||||
Function GetInterfaceLocalizationCode(AddInfo = Undefined) Export
|
||||
LangCode = "en";
|
||||
If Not IsBlankString(SessionParameters.InterfaceLocalizationCode) Then
|
||||
LangCode = TrimAll(SessionParameters.InterfaceLocalizationCode);
|
||||
EndIf;
|
||||
Return LangCode;
|
||||
EndFunction
|
||||
|
||||
// Fields list for descriptions.
|
||||
|
@@ -18,7 +18,7 @@
|
||||
// * DataLang - String -
|
||||
Function InitPrintParam(Ref, Val LayoutLang = Undefined, Val DataLang = Undefined) Export
|
||||
If LayoutLang = Undefined Then
|
||||
LayoutLang = LocalizationReuse.GetLocalizationCode();
|
||||
LayoutLang = LocalizationReuse.GetInterfaceLocalizationCode();
|
||||
EndIf;
|
||||
If DataLang = Undefined Then
|
||||
DataLang = LocalizationReuse.GetLocalizationCode();
|
||||
|
@@ -73,7 +73,7 @@ Procedure PresentationGetProcessing(Data, Presentation, StandardProcessing)
|
||||
If ValueIsFilled(Data.Basis) Then
|
||||
StandardProcessing = False;
|
||||
If TypeOf(Data.Basis) = Type("DocumentRef.ExternalAccountingOperation") Then
|
||||
PresentationBasis = Data.Basis["Description_" + LocalizationReuse.UserLanguageCode()];
|
||||
PresentationBasis = Data.Basis["Description_" + LocalizationReuse.GetLocalizationCode()];
|
||||
If IsBlankString(PresentationBasis) Then
|
||||
Presentation = ""+R().AccountingJE_prefix_01 + Data.Basis.RecorderPresentation;
|
||||
Else
|
||||
|
@@ -1,7 +1,7 @@
|
||||
|
||||
Procedure PresentationGetProcessing(Data, Presentation, StandardProcessing)
|
||||
StandardProcessing = False;
|
||||
Presentation = String(Data["Description_" + LocalizationReuse.UserLanguageCode()]);
|
||||
Presentation = String(Data["Description_" + LocalizationReuse.GetLocalizationCode()]);
|
||||
EndProcedure
|
||||
|
||||
Procedure PresentationFieldsGetProcessing(Fields, StandardProcessing)
|
||||
|
Reference in New Issue
Block a user