/// <summary> /// </summary> /// <param name="cultureInfo"> </param> public static void Update(CultureInfo cultureInfo) { var culture = cultureInfo.TwoLetterISOLanguageName; ResourceDictionary dictionary; if (Constants.Supported.Contains(culture)) { switch (culture) { case "fr": dictionary = French.Context(); break; case "ja": dictionary = Japanese.Context(); break; case "de": dictionary = German.Context(); break; case "zh": dictionary = Chinese.Context(); break; default: dictionary = English.Context(); break; } } else { dictionary = English.Context(); } var locale = dictionary.Cast <DictionaryEntry>() .ToDictionary(item => (string)item.Key, item => (string)item.Value); AppViewModel.Instance.Locale = locale; foreach (PluginInstance pluginInstance in App.Plugins.Loaded) { pluginInstance.Instance.Locale = locale; } }
public List <string> ToLowerTrimmedStrings() { var ret = new List <string>(); if (English != null) { ret.Add(English.Trim().ToLower()); } if (French != null) { ret.Add(French.Trim().ToLower()); } if (Arabic != null) { ret.Add(Arabic.Trim().ToLower()); } return(ret); }
/// <summary> /// </summary> /// <param name="cultureInfo"> </param> public static Dictionary <string, string> Update(CultureInfo cultureInfo) { var culture = cultureInfo.TwoLetterISOLanguageName; Dictionary <string, string> dictionary; if (Constants.Supported.Contains(culture)) { switch (culture) { case "fr": dictionary = French.Context(); break; case "ja": dictionary = Japanese.Context(); break; case "de": dictionary = German.Context(); break; case "zh": dictionary = Chinese.Context(); break; case "ru": dictionary = Russian.Context(); break; default: dictionary = English.Context(); break; } } else { dictionary = English.Context(); } var e = dictionary.ToDictionary(val => val.Key, val => val.Value); return(e); }
public override int GetHashCode() { int hashCode = 0; unchecked { if (German != null) { hashCode += 1000000007 * German.GetHashCode(); } if (English != null) { hashCode += 1000000009 * English.GetHashCode(); } if (French != null) { hashCode += 1000000021 * French.GetHashCode(); } } return(hashCode); }
public Core(string text, string inputLanguage, string outputLangage, out string output) { string inLang = ""; if (inputLanguage == "Latin") { inLang = "latin"; } else { throw new Exception("Unknown input language !"); } if (outputLangage == "Français") { output = French.ToFrench(text, inLang); return; } throw new Exception("Unknown output language !"); }
/// <summary> /// </summary> /// <param name="cultureInfo"> </param> public static Dictionary <string, string> Update(CultureInfo cultureInfo) { var culture = cultureInfo.TwoLetterISOLanguageName; ResourceDictionary dictionary; if (Constants.Supported.Contains(culture)) { switch (culture) { case "fr": dictionary = French.Context(); break; case "ja": dictionary = Japanese.Context(); break; case "de": dictionary = German.Context(); break; case "zh": dictionary = Chinese.Context(); break; case "ru": dictionary = Russian.Context(); break; default: dictionary = English.Context(); break; } } else { dictionary = English.Context(); } return(dictionary.Cast <DictionaryEntry>().ToDictionary(item => (string)item.Key, item => (string)item.Value)); }
static void Main(string[] args) { Console.Title = "Object Oriented Design Assignment 7: Adapter Pattern"; Console.WindowHeight = 30; Console.WindowWidth = 50; //Create Language objects: HumanLanguage English = new English(); HumanLanguage French = new French(); HumanLanguage Spanish = new Spanish(); MachineLanguage Binary = new Binary(); //This is the adapter for the binary language: HumanLanguage BinaryAdapter = new BinaryAdapter(Binary); Console.WriteLine("*************************************"); Console.WriteLine("*************************************"); Console.WriteLine("* Welcome to the Speech Simulator *"); Console.WriteLine("* Listed below are the words for *"); Console.WriteLine("* 'Hello' in various languages *"); Console.WriteLine("*************************************"); Console.WriteLine("*************************************"); Console.WriteLine(); //Print out hello in each language Console.WriteLine("English: "); English.sayHello(); Console.WriteLine(); Console.WriteLine("French: "); French.sayHello(); Console.WriteLine(); Console.WriteLine("Spanish: "); Spanish.sayHello(); Console.WriteLine(); //The adapter makes it possible for the binary object to sayHello: Console.WriteLine("Machine: "); BinaryAdapter.sayHello(); Console.ReadKey(); }
internal void LanguagePacksReadFromCache(Halo2.CacheFile c) { if (!English.IsLoaded) { English.ReadFromCache(c); } if (!Japanese.IsLoaded) { Japanese.ReadFromCache(c); } if (!German.IsLoaded) { German.ReadFromCache(c); } if (!French.IsLoaded) { French.ReadFromCache(c); } if (!Spanish.IsLoaded) { Spanish.ReadFromCache(c); } if (!Italian.IsLoaded) { Italian.ReadFromCache(c); } if (!Korean.IsLoaded) { Korean.ReadFromCache(c); } if (!Chinese.IsLoaded) { Chinese.ReadFromCache(c); } if (!Portuguese.IsLoaded) { Portuguese.ReadFromCache(c); } }
/////// <summary> /////// An asynchronous static method to create a new BIP39 from random entropy. The random entropy creation is CPU intensive so is run in its own Task and we await as per async pattern. /////// </summary> /////// <param name="entropySize">The size in bits of the entropy to be created</param> /////// <param name="passphrase">The optional passphrase. Please ensure NFKD Normalized, Empty string will be used if not provided as per spec</param> /////// <param name="language">The optional language. If no language is provided English will be used</param> /////// <returns>A BIP39 object</returns> ////public static async Task<BIP39> GetBIP39Async(int entropySize = cMinimumEntropyBits, string passphrase = cEmptyString, Language language = Language.English) ////{ //// byte[] entropyBytes = await Utilities.GetRandomBytesAsync(entropySize / cBitsInByte); //// return new BIP39(entropyBytes, passphrase, language); ////} /// <summary> /// Takes in a string[] of words and detects the language that has the highest number of matching words. /// </summary> /// <param name="words"> /// The words of which you wish to derive a language /// </param> /// <returns> /// The best attempt at a guessed Language /// </returns> public static Language AutoDetectLanguageOfWords(string[] words) { English eng = new English(); Japanese jp = new Japanese(); Spanish es = new Spanish(); French fr = new French(); ChineseSimplified cnS = new ChineseSimplified(); ChineseTraditional cnT = new ChineseTraditional(); List <int> languageCount = new List <int>(new[] { 0, 0, 0, 0, 0, 0 }); int index; foreach (string s in words) { if (eng.WordExists(s, out index)) { // english is at 0 languageCount[0]++; } if (jp.WordExists(s, out index)) { // japanese is at 1 languageCount[1]++; } if (es.WordExists(s, out index)) { // spanish is at 2 languageCount[2]++; } if (cnS.WordExists(s, out index)) { // chinese simplified is at 3 languageCount[3]++; } if (cnT.WordExists(s, out index) && !cnS.WordExists(s, out index)) { // chinese traditional is at 4 languageCount[4]++; } if (fr.WordExists(s, out index)) { // french is at 5 languageCount[5]++; } } // no hits found for any language unknown if (languageCount.Max() == 0) { return(Language.Unknown); } if (languageCount.IndexOf(languageCount.Max()) == 0) { return(Language.English); } if (languageCount.IndexOf(languageCount.Max()) == 1) { return(Language.Japanese); } if (languageCount.IndexOf(languageCount.Max()) == 2) { return(Language.Spanish); } if (languageCount.IndexOf(languageCount.Max()) == 3) { if (languageCount[4] > 0) { // has traditional characters so not simplified but instead traditional return(Language.ChineseTraditional); } return(Language.ChineseSimplified); } if (languageCount.IndexOf(languageCount.Max()) == 4) { return(Language.ChineseTraditional); } if (languageCount.IndexOf(languageCount.Max()) == 5) { return(Language.French); } return(Language.Unknown); }
public bool Contains(string value) { value = value.Trim().ToLower(); return(value == English.Trim().ToLower() || value == French.Trim().ToLower() || value == Arabic.Trim().ToLower()); }
public async Task <IActionResult> Post([FromBody] French value) { await _frenchQManager.AddQuote(value); return(Ok()); }
/// <summary> /// This is run each time the app runs, but won't do anything after the first run. /// </summary> public void CreateDatabase() { try { if (!File.Exists(Settings.DatabaseFile)) { string categoriesSql = "CREATE TABLE \"categories\" (" + "\"id\" INTEGER PRIMARY KEY AUTOINCREMENT," + "\"name\" TEXT NOT NULL," + "\"active\" INTEGER DEFAULT 0," + "\"inbuilt\" INTEGER DEFAULT 0)"; string questionsSql = "CREATE TABLE questions (" + "\"id\" INTEGER PRIMARY KEY AUTOINCREMENT," + "\"categoryid\" INTEGER," + "\"title\" TEXT," + "\"answer\" TEXT," + "\"order\" INTEGER DEFAULT 0," + "\"lastasked\" INTEGER DEFAULT 0," + "\"nextaskon\" INTEGER DEFAULT 0," + "\"previousinterval\" INTEGER DEFAULT 0," + "\"interval\" INTEGER DEFAULT 0," + "\"askcount\" INTEGER DEFAULT 0," + "\"responsequality\" INTEGER DEFAULT 0," + "\"easinessfactor\" REAL DEFAULT 0)"; // Create the file SqliteConnection.CreateFile(Settings.DatabaseFile); // And the schema using (SqliteConnection connection = new SqliteConnection(Settings.DatabaseConnection)) { connection.Open(); using (SqliteCommand command = new SqliteCommand(connection)) { command.CommandText = categoriesSql; command.ExecuteNonQuery(); command.CommandText = questionsSql; command.ExecuteNonQuery(); // Default category command.CommandText = Default.Sql(); command.ExecuteNonQuery(); #if GERMAN command.CommandText = German.Sql(); command.ExecuteNonQuery(); #elif SPANISH command.CommandText = Spanish.Sql(); command.ExecuteNonQuery(); #elif FRENCH command.CommandText = French.Sql(); command.ExecuteNonQuery(); #endif } } } } catch (IOException ex) { Logger.Fatal("Unable to delete the database file {0}: \n{1}", Settings.DatabaseFile, ex); throw; } catch (SqliteException ex) { Logger.Fatal("Unable to create the database: \n{0}", ex); throw; } }
public static Language AutoDetectLanguage(string[] words) { var languageCount = new List <int>(new[] { 0, 0, 0, 0, 0, 0, 0 }); int index; foreach (var s in words) { if (English.WordExists(s, out index)) { //english is at 0 languageCount[0]++; } if (Japanese.WordExists(s, out index)) { //japanese is at 1 languageCount[1]++; } if (Spanish.WordExists(s, out index)) { //spanish is at 2 languageCount[2]++; } if (ChineseSimplified.WordExists(s, out index)) { //chinese simplified is at 3 languageCount[3]++; } if (ChineseTraditional.WordExists(s, out index) && !ChineseSimplified.WordExists(s, out index)) { //chinese traditional is at 4 languageCount[4]++; } if (French.WordExists(s, out index)) { languageCount[5]++; } if (PortugueseBrazil.WordExists(s, out index)) { //portuguese_brazil is at 6 languageCount[6]++; } } //no hits found for any language unknown if (languageCount.Max() == 0) { return(Language.Unknown); } if (languageCount.IndexOf(languageCount.Max()) == 0) { return(Language.English); } if (languageCount.IndexOf(languageCount.Max()) == 1) { return(Language.Japanese); } if (languageCount.IndexOf(languageCount.Max()) == 2) { return(Language.Spanish); } if (languageCount.IndexOf(languageCount.Max()) == 3) { if (languageCount[4] > 0) { //has traditional characters so not simplified but instead traditional return(Language.ChineseTraditional); } return(Language.ChineseSimplified); } if (languageCount.IndexOf(languageCount.Max()) == 4) { return(Language.ChineseTraditional); } if (languageCount.IndexOf(languageCount.Max()) == 5) { return(Language.French); } if (languageCount.IndexOf(languageCount.Max()) == 6) { return(Language.PortugueseBrazil); } return(Language.Unknown); }
public string Greetings(French french) { return french.DireBonjour(); }
public LanguageFrenchBuilder(string line) { modifiedLine = line; language = new French(); }
static void Main(string[] args) { Employee Jack = new Employee(); Jack.SetFullName("Jack Jackson"); Jack.SetSalary(300000); //Employee Jack = new Employee("Jack Jackson", 300000); //inherited classes ITExecutives Jill = new ITExecutives(); Jill.SetFullName("Jill White"); Jill.SetSalary(400000); // SalesExecutive John = new SalesExecutive(); //wont work since no parameterless ctor exists SalesExecutive John = new SalesExecutive("John Parker", 300000, 120); John.Sales = 20; EmployeeInfo(Jack); EmployeeInfo(Jill); EmployeeInfo(John); /////////////////////////// //LivingBeing x = new LivingBeing(); Humans human = new Humans(); Cow cow = new Cow(); Cat cat = new Cat(); French frman = new French(); Spanish spman = new Spanish(); List <LivingBeing> livingBeings = new List <LivingBeing>(); livingBeings.Add(human); livingBeings.Add(cat); livingBeings.Add(cow); livingBeings.Add(frman); livingBeings.Add(spman); Talk(livingBeings); /////////// //casting Car Nissan = new Car { RegNos = 122, TopSpeed = 120 }; Car Audi = new Car { RegNos = 221, TopSpeed = 170 }; Truck Tata = new Truck { RegNos = 1011, IsLoaded = false, NoOfTyres = 10 }; Truck Mazda = new Truck { RegNos = 50501, IsLoaded = true, NoOfTyres = 8 }; List <Vehicle> vehicles = new List <Vehicle> { Nissan, Audi, Tata, Mazda }; VehicleGarrage(vehicles); Console.ReadKey(); }