1 /*************************************************************************** 2 * Free Heroes of Might and Magic II: https://github.com/ihhub/fheroes2 * 3 * Copyright (C) 2021 * 4 * * 5 * This program is free software; you can redistribute it and/or modify * 6 * it under the terms of the GNU General Public License as published by * 7 * the Free Software Foundation; either version 2 of the License, or * 8 * (at your option) any later version. * 9 * * 10 * This program is distributed in the hope that it will be useful, * 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 13 * GNU General Public License for more details. * 14 * * 15 * You should have received a copy of the GNU General Public License * 16 * along with this program; if not, write to the * 17 * Free Software Foundation, Inc., * 18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 19 ***************************************************************************/ 20 21 #pragma once 22 23 #include <string> 24 #include <vector> 25 26 namespace fheroes2 27 { 28 enum class SupportedLanguage : int 29 { 30 English = 0, // default language for all version of the game. 31 French, // GoG version 32 Polish, // GoG version 33 German, // GoG version 34 Russian, // Buka and XXI Vek versions 35 Italian // Rare version? 36 }; 37 38 class LanguageSwitcher 39 { 40 public: 41 LanguageSwitcher() = delete; 42 43 LanguageSwitcher( const LanguageSwitcher & ) = delete; 44 LanguageSwitcher( const LanguageSwitcher && ) = delete; 45 LanguageSwitcher & operator=( const LanguageSwitcher & ) = delete; 46 LanguageSwitcher & operator=( const LanguageSwitcher && ) = delete; 47 48 explicit LanguageSwitcher( const SupportedLanguage language ); 49 ~LanguageSwitcher(); 50 51 private: 52 const std::string _currentLanguage; 53 }; 54 55 // This function returns an array of supported languages. If the array contains only one language it must be English. 56 std::vector<SupportedLanguage> getSupportedLanguages(); 57 58 // Return name of the language. Call this function only within the scope of LanguageSwitcher object. 59 const char * getLanguageName( const SupportedLanguage language ); 60 61 const char * getLanguageAbbreviation( const SupportedLanguage language ); 62 63 SupportedLanguage getLanguageFromAbbreviation( const std::string & abbreviation ); 64 65 void updateAlphabet( const std::string & abbreviation ); 66 } 67