mirror of
				https://github.com/MindWorkAI/AI-Studio.git
				synced 2025-11-04 14:20:22 +00:00 
			
		
		
		
	Add LangName property to language plugin interface and implementation
This commit is contained in:
		
							parent
							
								
									445fc579ac
								
							
						
					
					
						commit
						7f6190a883
					
				@ -44,6 +44,9 @@ DEPRECATION_MESSAGE = ""
 | 
				
			|||||||
-- code followed by the ISO 3166-1 country code:
 | 
					-- code followed by the ISO 3166-1 country code:
 | 
				
			||||||
IETF_TAG = "de-DE"
 | 
					IETF_TAG = "de-DE"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- The language name in the user's language:
 | 
				
			||||||
 | 
					LANG_NAME = "Deutsch (Deutschland)"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
UI_TEXT_CONTENT = {
 | 
					UI_TEXT_CONTENT = {
 | 
				
			||||||
    HOME = CONTENT_HOME,
 | 
					    HOME = CONTENT_HOME,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -44,6 +44,9 @@ DEPRECATION_MESSAGE = ""
 | 
				
			|||||||
-- code followed by the ISO 3166-1 country code:
 | 
					-- code followed by the ISO 3166-1 country code:
 | 
				
			||||||
IETF_TAG = "en-US"
 | 
					IETF_TAG = "en-US"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- The language name in the user's language:
 | 
				
			||||||
 | 
					LANG_NAME = "English (United States)"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
UI_TEXT_CONTENT = {
 | 
					UI_TEXT_CONTENT = {
 | 
				
			||||||
    HOME = CONTENT_HOME,
 | 
					    HOME = CONTENT_HOME,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -23,4 +23,9 @@ public interface ILanguagePlugin
 | 
				
			|||||||
    /// Gets the IETF tag of the language plugin.
 | 
					    /// Gets the IETF tag of the language plugin.
 | 
				
			||||||
    /// </summary>
 | 
					    /// </summary>
 | 
				
			||||||
    public string IETFTag { get; }
 | 
					    public string IETFTag { get; }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    /// <summary>
 | 
				
			||||||
 | 
					    /// Gets the name of the language.
 | 
				
			||||||
 | 
					    /// </summary>
 | 
				
			||||||
 | 
					    public string LangName { get; }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -7,6 +7,7 @@ public sealed class PluginLanguage : PluginBase, ILanguagePlugin
 | 
				
			|||||||
    private readonly Dictionary<string, string> content = [];
 | 
					    private readonly Dictionary<string, string> content = [];
 | 
				
			||||||
    private readonly List<ILanguagePlugin> otherLanguagePlugins = [];
 | 
					    private readonly List<ILanguagePlugin> otherLanguagePlugins = [];
 | 
				
			||||||
    private readonly string langCultureTag;
 | 
					    private readonly string langCultureTag;
 | 
				
			||||||
 | 
					    private readonly string langName;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    private ILanguagePlugin? baseLanguage;
 | 
					    private ILanguagePlugin? baseLanguage;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
@ -15,6 +16,9 @@ public sealed class PluginLanguage : PluginBase, ILanguagePlugin
 | 
				
			|||||||
        if(!this.TryInitIETFTag(out var issue, out this.langCultureTag))
 | 
					        if(!this.TryInitIETFTag(out var issue, out this.langCultureTag))
 | 
				
			||||||
            this.pluginIssues.Add(issue);
 | 
					            this.pluginIssues.Add(issue);
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
 | 
					        if(!this.TryInitLangName(out issue, out this.langName))
 | 
				
			||||||
 | 
					            this.pluginIssues.Add(issue);
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
        if (this.TryInitUITextContent(out issue, out var readContent))
 | 
					        if (this.TryInitUITextContent(out issue, out var readContent))
 | 
				
			||||||
            this.content = readContent;
 | 
					            this.content = readContent;
 | 
				
			||||||
        else
 | 
					        else
 | 
				
			||||||
@ -128,6 +132,31 @@ public sealed class PluginLanguage : PluginBase, ILanguagePlugin
 | 
				
			|||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 | 
					    private bool TryInitLangName(out string message, out string readLangName)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (!this.state.Environment["LANG_NAME"].TryRead(out readLangName))
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            message = "The field LANG_NAME does not exist or is not a valid string.";
 | 
				
			||||||
 | 
					            readLangName = string.Empty;
 | 
				
			||||||
 | 
					            return false;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (string.IsNullOrWhiteSpace(readLangName))
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            message = "The field LANG_NAME is empty. Use a valid language name.";
 | 
				
			||||||
 | 
					            readLangName = string.Empty;
 | 
				
			||||||
 | 
					            return false;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        message = string.Empty;
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// <inheritdoc />
 | 
					    /// <inheritdoc />
 | 
				
			||||||
    public string IETFTag => this.langCultureTag;
 | 
					    public string IETFTag => this.langCultureTag;
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    /// <inheritdoc />
 | 
				
			||||||
 | 
					    public string LangName => this.langName;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    #endregion
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user