2018-01-29 16:25:32 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2022-07-09 22:23:34 +08:00
|
|
|
https://axis-project.github.io/
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2018-01-29 16:25:32 +08:00
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2018-01-29 16:25:32 +08:00
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2018-01-29 16:25:32 +08:00
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
#include "CurrentLanguageTest.h"
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
USING_NS_AX;
|
2015-04-09 08:37:30 +08:00
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
CurrentLanguageTests::CurrentLanguageTests()
|
|
|
|
{
|
|
|
|
ADD_TEST_CASE(CurrentLanguageTest);
|
|
|
|
}
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
CurrentLanguageTest::CurrentLanguageTest()
|
|
|
|
{
|
2014-04-09 23:31:05 +08:00
|
|
|
auto label = Label::createWithTTF("Current language Test", "fonts/arial.ttf", 28);
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(label, 0);
|
2021-12-28 16:06:23 +08:00
|
|
|
label->setPosition(VisibleRect::center().x, VisibleRect::top().y - 50);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2014-04-09 23:31:05 +08:00
|
|
|
auto labelLanguage = Label::createWithTTF("", "fonts/arial.ttf", 20);
|
2012-10-23 17:48:50 +08:00
|
|
|
labelLanguage->setPosition(VisibleRect::center());
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2014-10-11 15:19:20 +08:00
|
|
|
auto labelLanguageCode = Label::createWithTTF("", "fonts/arial.ttf", 20);
|
2021-12-28 16:06:23 +08:00
|
|
|
labelLanguageCode->setPosition(VisibleRect::center().x, VisibleRect::center().y - 50);
|
|
|
|
|
2014-10-11 15:19:20 +08:00
|
|
|
const char* currentLanguageCode = Application::getInstance()->getCurrentLanguageCode();
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2014-10-11 15:19:20 +08:00
|
|
|
labelLanguageCode->setString(currentLanguageCode);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-07-26 17:29:06 +08:00
|
|
|
LanguageType currentLanguageType = Application::getInstance()->getCurrentLanguage();
|
2012-04-19 14:35:52 +08:00
|
|
|
switch (currentLanguageType)
|
|
|
|
{
|
2013-07-26 17:29:06 +08:00
|
|
|
case LanguageType::ENGLISH:
|
2012-04-19 14:35:52 +08:00
|
|
|
labelLanguage->setString("current language is English");
|
|
|
|
break;
|
2013-07-26 17:29:06 +08:00
|
|
|
case LanguageType::CHINESE:
|
2012-04-19 14:35:52 +08:00
|
|
|
labelLanguage->setString("current language is Chinese");
|
|
|
|
break;
|
2013-07-26 17:29:06 +08:00
|
|
|
case LanguageType::FRENCH:
|
2012-04-19 14:35:52 +08:00
|
|
|
labelLanguage->setString("current language is French");
|
|
|
|
break;
|
2013-07-26 17:29:06 +08:00
|
|
|
case LanguageType::GERMAN:
|
2012-04-19 14:35:52 +08:00
|
|
|
labelLanguage->setString("current language is German");
|
|
|
|
break;
|
2013-07-26 17:29:06 +08:00
|
|
|
case LanguageType::ITALIAN:
|
2012-04-19 14:35:52 +08:00
|
|
|
labelLanguage->setString("current language is Italian");
|
|
|
|
break;
|
2013-07-26 17:29:06 +08:00
|
|
|
case LanguageType::RUSSIAN:
|
2012-04-19 14:35:52 +08:00
|
|
|
labelLanguage->setString("current language is Russian");
|
|
|
|
break;
|
2013-07-26 17:29:06 +08:00
|
|
|
case LanguageType::SPANISH:
|
2012-04-19 14:35:52 +08:00
|
|
|
labelLanguage->setString("current language is Spanish");
|
|
|
|
break;
|
2013-07-26 17:29:06 +08:00
|
|
|
case LanguageType::KOREAN:
|
2012-10-19 09:41:46 +08:00
|
|
|
labelLanguage->setString("current language is Korean");
|
|
|
|
break;
|
2013-07-26 17:29:06 +08:00
|
|
|
case LanguageType::JAPANESE:
|
2012-11-28 16:53:10 +08:00
|
|
|
labelLanguage->setString("current language is Japanese");
|
|
|
|
break;
|
2013-07-26 17:29:06 +08:00
|
|
|
case LanguageType::HUNGARIAN:
|
2012-12-05 18:31:05 +08:00
|
|
|
labelLanguage->setString("current language is Hungarian");
|
|
|
|
break;
|
2013-07-26 17:29:06 +08:00
|
|
|
case LanguageType::PORTUGUESE:
|
2013-03-03 10:32:09 +08:00
|
|
|
labelLanguage->setString("current language is Portuguese");
|
|
|
|
break;
|
2013-07-26 17:29:06 +08:00
|
|
|
case LanguageType::ARABIC:
|
2013-03-03 10:32:09 +08:00
|
|
|
labelLanguage->setString("current language is Arabic");
|
|
|
|
break;
|
2013-07-26 17:29:06 +08:00
|
|
|
case LanguageType::NORWEGIAN:
|
2013-05-29 16:31:46 +08:00
|
|
|
labelLanguage->setString("current language is Norwegian");
|
|
|
|
break;
|
2013-07-26 17:29:06 +08:00
|
|
|
case LanguageType::POLISH:
|
2013-06-21 03:15:42 +08:00
|
|
|
labelLanguage->setString("current language is Polish");
|
|
|
|
break;
|
2014-03-05 15:04:30 +08:00
|
|
|
case LanguageType::DUTCH:
|
|
|
|
labelLanguage->setString("current language is Polish");
|
|
|
|
break;
|
|
|
|
default:
|
2022-07-16 10:43:05 +08:00
|
|
|
AXASSERT(false, "Invalid language type.");
|
2014-03-05 15:04:30 +08:00
|
|
|
break;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
addChild(labelLanguage);
|
2014-10-11 15:19:20 +08:00
|
|
|
addChild(labelLanguageCode);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|