/// <summary> /// Returns ILanguage by name. /// </summary> /// <param name="lang"></param> /// <returns>ILanguage with specified name</returns> public ILanguage GetLanguage(string lang) { switch (lang.Trim().ToLower()) { case "russian": return(Russian.GetInstance()); case "english": return(English.GetInstance()); default: return(DefaultLanguage.GetInstance()); } }
/// <summary> /// Determinate language what can be used for translating article. /// </summary> /// <param name="article"></param> /// <returns></returns> public ILanguage DeterminateLanguage(IArticle article) { for (int i = 0; i < article.Text.Length; i++) { if (0x41 < article.Text[i] && article.Text[i] < 0x7a) { return(English.GetInstance()); } if (0x410 < article.Text[i] && article.Text[i] < 0x44f) { return(Russian.GetInstance()); } } return(DefaultLanguage.GetInstance()); }
/// <summary> /// Determinate language what can be used for specified string. /// </summary> /// <param name="text"></param> /// <returns>ILanguage corresponding to text.</returns> public ILanguage DeterminateLanguage(string text) { if (text == null) { return(null); } for (int i = 0; i < text.Length; i++) { if (0x41 < text[i] && text[i] < 0x7a) { return(English.GetInstance()); } if (0x410 < text[i] && text[i] < 0x44f) { return(Russian.GetInstance()); } } return(DefaultLanguage.GetInstance()); }