1 /* bzflag 2 * Copyright (c) 1993-2021 Tim Riker 3 * 4 * This package is free software; you can redistribute it and/or 5 * modify it under the terms of the license found in the file 6 * named COPYING that should have accompanied this file. 7 * 8 * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 9 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 10 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 11 */ 12 13 #ifndef __LANGUAGE_H__ 14 #define __LANGUAGE_H__ 15 16 #include "common.h" 17 18 // system interface headers 19 #include <string> 20 #include <vector> 21 22 23 /** ISO 639 language representation */ 24 class Language 25 { 26 private: 27 int _number; 28 std::string _iso2; 29 std::string _iso3; 30 std::string _english; 31 std::string _french; 32 33 static std::vector<Language> _language; 34 35 protected: 36 37 Language(int numberCode, std::string iso2Code, std::string iso3Code="", std::string english="", std::string french=""); 38 ~Language(); 39 40 static bool addLanguage(Language& language); 41 42 public: 43 44 /** loads entries from a file and return the count added */ 45 static unsigned int loadFromFile(std::string filename, bool verbose=false); 46 47 /** returns the language code */ 48 int number() const; 49 /** returns the 2-char language abbreviation */ 50 std::string iso2() const; 51 /** returns the 3-char language abbreviation */ 52 std::string iso3() const; 53 /** returns the english name for display */ 54 std::string englishName() const; 55 /** returns the french name for display */ 56 std::string frenchName() const; 57 58 59 /** returns the language code */ 60 static int number(int code); 61 static int number(std::string language); 62 /** returns the 2-char language abbreviation */ 63 static std::string iso2(int code); 64 static std::string iso2(std::string language); 65 /** returns the 3-char language abbreviation */ 66 static std::string iso3(int code); 67 static std::string iso3(std::string language); 68 /** returns the english name for display */ 69 static std::string englishName(int code); 70 static std::string englishName(std::string language); 71 /** returns the french name for display */ 72 static std::string frenchName(int code); 73 static std::string frenchName(std::string language); 74 75 /* 76 static const Language CHINESE = Language("zh"); 77 static const Language ENGLISH = Language("en"); 78 static const Language FRENCH = Language("fr"); 79 static const Language GERMAN = Language("de"); 80 static const Language ITALIAN = Language("it"); 81 static const Language JAPANESE = Language("jp"); 82 static const Language KOREAN = Language("ko"); 83 static const Language SIMPLIFIED_CHINESE = Language("zh"); 84 static const Language TRADITIONAL_CHINESE = Language("zh"); 85 */ 86 87 }; /* class Language */ 88 89 90 #else 91 class Language; 92 #endif 93 94 // Local Variables: *** 95 // mode: C++ *** 96 // tab-width: 4 *** 97 // c-basic-offset: 4 *** 98 // indent-tabs-mode: nil *** 99 // End: *** 100 // ex: shiftwidth=4 tabstop=4 101