Exemple #1
0
 /// <summary>
 /// Add a language to the supported language
 /// </summary>
 /// <param name="language"></param>
 /// <returns>It returns this</returns>
 /// <remarks>Thread Safe at expense of speeed</remarks>
 public LangSet Add(string language, bool defaultVal = false)
 {
     lock (supported)
     {
         Lang l = Lang.Parse(language);
         supported.Add(l);
         if (this.defaultLang == null || defaultVal)
         {
             this.defaultLang = l;
         }
     }
     return(this);
 }
Exemple #2
0
        /// <summary>
        /// Return the language closest to langDef in the supported list
        /// </summary>
        /// <param name="langDef">language to find </param>
        /// <returns>best match found or default</returns>
        /// <remarks>
        /// The idea is to find the closest language using this policy:
        ///
        /// - a language whose is in the same family of the searched language is always better than another language
        ///
        /// for example
        ///
        /// xx-xxx-Xxxx-XX-x-xxxxxxxx-xxxxx-xxxxxx-x-xxxxxx-xxxx
        /// is a better match to
        /// yy-yyy-Yyyy-YY-y-yyyyyyyy-yyyyy
        ///
        /// if yy is a sublanguage of the same macrolanguage than the default
        ///
        /// and so on the same policy is applied in cascade
        ///
        /// example: ( X = Y means X match Y, X = Y > Z means that Y match X better than Z)
        ///
        /// de-CH is a better match to de-DE than the default
        ///
        ///
        /// de-CH-1901 = de-CH > de > default ; cause it match language and region even if orthography is old.
        ///
        /// to match the variants: greater number of variant matches is always better than lower match of matches
        ///
        /// In the case of equal matching, the shortest one is preferred
        /// </remarks>

        public Lang Lookup(string language)
        {
            return(Lookup(Lang.Parse(language)));
        }