From adc80cd71ba04a9b27552a6ddf1f0b341af23439 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Tue, 14 Mar 2017 16:21:36 +0100 Subject: [PATCH] [apps][escher] I18n Change-Id: I4d6f40155a8a182184af9ef2a583d0469196ffd5 --- apps/Makefile | 1 + apps/apps_window.cpp | 2 +- apps/apps_window.h | 2 +- apps/calculation/app.cpp | 3 +- .../edit_expression_controller.cpp | 4 - apps/calculation/edit_expression_controller.h | 1 - apps/calculation/history_controller.cpp | 4 - apps/calculation/history_controller.h | 1 - apps/global_preferences.cpp | 6 +- apps/global_preferences.h | 13 +- apps/graph/app.cpp | 3 +- .../graph/curve_parameter_controller.cpp | 10 +- apps/graph/graph/curve_parameter_controller.h | 2 +- apps/graph/graph/graph_controller.cpp | 6 +- apps/graph/graph/graph_controller.h | 2 +- apps/graph/list/list_controller.cpp | 9 +- apps/graph/list/list_controller.h | 2 +- .../derivative_parameter_controller.cpp | 20 +- .../values/derivative_parameter_controller.h | 2 +- .../values/function_parameter_controller.cpp | 2 +- apps/graph/values/values_controller.cpp | 10 +- apps/graph/values/values_controller.h | 2 +- apps/home/app.cpp | 4 +- apps/home/app_cell.cpp | 4 +- apps/home/controller.cpp | 4 + apps/home/controller.h | 1 + apps/i18n.cpp | 359 ++++++++++++++++++ apps/i18n.h | 315 +++++++++++++++ apps/math_toolbox.cpp | 46 +-- apps/math_toolbox.h | 2 +- apps/node.cpp | 4 +- apps/node.h | 8 +- apps/picview/picview_controller.cpp | 2 +- apps/probability/app.cpp | 4 +- apps/probability/calculation/calculation.h | 2 +- .../finite_integral_calculation.cpp | 9 +- .../calculation/finite_integral_calculation.h | 2 +- .../calculation/left_integral_calculation.cpp | 7 +- .../calculation/left_integral_calculation.h | 2 +- .../right_integral_calculation.cpp | 7 +- .../calculation/right_integral_calculation.h | 2 +- apps/probability/calculation_controller.cpp | 18 +- apps/probability/calculation_controller.h | 2 +- apps/probability/cell.cpp | 6 +- apps/probability/cell.h | 2 +- apps/probability/law/binomial_law.cpp | 16 +- apps/probability/law/binomial_law.h | 6 +- apps/probability/law/exponential_law.cpp | 14 +- apps/probability/law/exponential_law.h | 6 +- apps/probability/law/law.h | 8 +- apps/probability/law/normal_law.cpp | 20 +- apps/probability/law/normal_law.h | 6 +- apps/probability/law/poisson_law.cpp | 14 +- apps/probability/law/poisson_law.h | 6 +- apps/probability/law/uniform_law.cpp | 16 +- apps/probability/law/uniform_law.h | 6 +- apps/probability/law_controller.cpp | 14 +- apps/probability/law_controller.h | 2 +- apps/probability/parameters_controller.cpp | 18 +- apps/probability/parameters_controller.h | 2 +- apps/regression/app.cpp | 3 +- apps/regression/banner_view.cpp | 9 +- apps/regression/banner_view.h | 1 + apps/regression/calculation_controller.cpp | 16 +- apps/regression/calculation_controller.h | 4 +- .../regression/go_to_parameter_controller.cpp | 10 +- apps/regression/go_to_parameter_controller.h | 2 +- apps/regression/graph_controller.cpp | 8 +- apps/regression/graph_controller.h | 4 +- .../initialisation_parameter_controller.cpp | 8 +- .../initialisation_parameter_controller.h | 3 +- .../prediction_parameter_controller.cpp | 8 +- .../prediction_parameter_controller.h | 2 +- apps/sequence/app.cpp | 2 +- .../graph/curve_parameter_controller.cpp | 8 +- .../graph/curve_parameter_controller.h | 2 +- apps/sequence/graph/graph_controller.cpp | 6 +- apps/sequence/graph/graph_controller.h | 2 +- apps/sequence/graph/term_sum_controller.cpp | 39 +- apps/sequence/graph/term_sum_controller.h | 8 +- apps/sequence/list/list_controller.cpp | 6 +- apps/sequence/list/list_controller.h | 2 +- .../list/list_parameter_controller.cpp | 8 +- .../sequence/list/list_parameter_controller.h | 2 +- .../list/type_parameter_controller.cpp | 12 +- .../sequence/list/type_parameter_controller.h | 2 +- apps/sequence/values/values_controller.cpp | 10 +- apps/sequence/values/values_controller.h | 2 +- apps/settings/app.cpp | 3 +- apps/settings/main_controller.cpp | 24 +- apps/settings/main_controller.h | 2 +- apps/settings/settings_node.h | 2 +- apps/settings/sub_controller.cpp | 14 +- apps/settings/sub_controller.h | 2 +- apps/shared/banner_view.cpp | 10 + apps/shared/banner_view.h | 2 + apps/shared/button_with_separator.cpp | 4 +- apps/shared/button_with_separator.h | 2 +- .../editable_cell_table_view_controller.cpp | 2 +- apps/shared/float_parameter_controller.cpp | 4 +- apps/shared/float_parameter_controller.h | 2 +- .../function_curve_parameter_controller.cpp | 4 +- .../function_curve_parameter_controller.h | 2 +- apps/shared/go_to_parameter_controller.cpp | 10 +- apps/shared/go_to_parameter_controller.h | 4 +- .../initialisation_parameter_controller.cpp | 8 +- .../initialisation_parameter_controller.h | 3 +- .../interactive_curve_view_controller.cpp | 10 +- .../interactive_curve_view_controller.h | 2 +- apps/shared/interval_parameter_controller.cpp | 12 +- apps/shared/interval_parameter_controller.h | 2 +- apps/shared/list_controller.cpp | 6 +- apps/shared/list_controller.h | 3 +- apps/shared/list_parameter_controller.cpp | 16 +- apps/shared/list_parameter_controller.h | 5 +- apps/shared/new_function_cell.cpp | 2 +- apps/shared/new_function_cell.h | 2 +- apps/shared/range_parameter_controller.cpp | 16 +- apps/shared/range_parameter_controller.h | 2 +- apps/shared/store_controller.cpp | 4 +- apps/shared/store_controller.h | 2 +- apps/shared/store_parameter_controller.cpp | 10 +- apps/shared/store_parameter_controller.h | 3 +- apps/shared/text_field_delegate_app.cpp | 9 +- apps/shared/text_field_delegate_app.h | 3 +- apps/shared/values_controller.cpp | 10 +- apps/shared/values_controller.h | 5 +- .../values_function_parameter_controller.cpp | 30 +- .../values_function_parameter_controller.h | 4 +- apps/shared/values_parameter_controller.cpp | 20 +- apps/shared/values_parameter_controller.h | 7 +- apps/shared/zoom_parameter_controller.cpp | 14 +- apps/shared/zoom_parameter_controller.h | 3 +- apps/statistics/app.cpp | 2 +- apps/statistics/box_banner_view.cpp | 9 +- apps/statistics/box_banner_view.h | 2 + apps/statistics/box_controller.cpp | 13 +- apps/statistics/box_controller.h | 4 +- apps/statistics/calculation_controller.cpp | 14 +- apps/statistics/calculation_controller.h | 4 +- apps/statistics/histogram_banner_view.cpp | 18 +- apps/statistics/histogram_banner_view.h | 5 + apps/statistics/histogram_controller.cpp | 22 +- apps/statistics/histogram_controller.h | 6 +- .../histogram_parameter_controller.cpp | 14 +- .../histogram_parameter_controller.h | 2 +- apps/statistics/store_controller.cpp | 4 +- apps/title_bar_view.cpp | 6 +- apps/title_bar_view.h | 3 +- apps/toolbox_node.cpp | 2 +- apps/toolbox_node.h | 6 +- apps/variable_box_controller.cpp | 12 +- apps/variable_box_controller.h | 5 +- escher/include/escher.h | 1 + .../escher/alternate_empty_view_controller.h | 3 +- .../escher/alternate_empty_view_delegate.h | 3 +- escher/include/escher/app.h | 13 +- escher/include/escher/button.h | 3 +- escher/include/escher/button_row_controller.h | 3 +- .../escher/even_odd_pointer_text_cell.h | 3 +- .../expression_table_cell_with_pointer.h | 5 +- escher/include/escher/i18n.h | 13 + escher/include/escher/input_view_controller.h | 1 - escher/include/escher/menu_view.h | 14 - escher/include/escher/modal_view_controller.h | 1 - escher/include/escher/pointer_table_cell.h | 5 +- .../escher/pointer_table_cell_with_buffer.h | 2 +- .../escher/pointer_table_cell_with_chevron.h | 2 +- ...r_table_cell_with_chevron_and_expression.h | 2 +- ...nter_table_cell_with_chevron_and_pointer.h | 2 +- .../pointer_table_cell_with_editable_text.h | 2 +- .../escher/pointer_table_cell_with_pointer.h | 5 +- .../escher/pointer_table_cell_with_switch.h | 2 +- escher/include/escher/pointer_text_view.h | 8 +- escher/include/escher/stack_view.h | 10 +- escher/include/escher/stack_view_controller.h | 4 +- escher/include/escher/tab_view.h | 4 +- escher/include/escher/tab_view_cell.h | 6 +- escher/include/escher/table_cell.h | 4 +- escher/include/escher/view_controller.h | 3 +- escher/include/escher/warning_controller.h | 10 +- .../src/alternate_empty_view_controller.cpp | 6 +- escher/src/app.cpp | 10 +- escher/src/button.cpp | 2 +- escher/src/button_row_controller.cpp | 2 +- escher/src/even_odd_pointer_text_cell.cpp | 6 +- .../expression_table_cell_with_pointer.cpp | 8 +- escher/src/input_view_controller.cpp | 4 - escher/src/modal_view_controller.cpp | 4 - escher/src/pointer_table_cell.cpp | 6 +- escher/src/pointer_table_cell_with_buffer.cpp | 4 +- .../src/pointer_table_cell_with_chevron.cpp | 4 +- ...table_cell_with_chevron_and_expression.cpp | 4 +- ...er_table_cell_with_chevron_and_pointer.cpp | 8 +- .../pointer_table_cell_with_editable_text.cpp | 4 +- .../src/pointer_table_cell_with_pointer.cpp | 14 +- escher/src/pointer_table_cell_with_switch.cpp | 4 +- escher/src/pointer_text_view.cpp | 15 +- escher/src/stack_view.cpp | 31 +- escher/src/stack_view_controller.cpp | 10 +- escher/src/tab_view.cpp | 5 +- escher/src/tab_view_cell.cpp | 14 +- escher/src/tab_view_controller.cpp | 2 +- escher/src/view_controller.cpp | 2 +- escher/src/warning_controller.cpp | 17 +- quiz/Makefile | 2 +- quiz/src/i18n.cpp | 10 + 207 files changed, 1384 insertions(+), 669 deletions(-) create mode 100644 apps/i18n.cpp create mode 100644 apps/i18n.h create mode 100644 escher/include/escher/i18n.h delete mode 100644 escher/include/escher/menu_view.h create mode 100644 quiz/src/i18n.cpp diff --git a/apps/Makefile b/apps/Makefile index 40e23ee5c..35a4b1a80 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -15,6 +15,7 @@ app_objs += $(addprefix apps/,\ battery_view.o\ constant.o\ global_preferences.o\ + i18n.o\ main.o\ math_toolbox.o\ node.o\ diff --git a/apps/apps_window.cpp b/apps/apps_window.cpp index 0e9253743..a3b322db6 100644 --- a/apps/apps_window.cpp +++ b/apps/apps_window.cpp @@ -9,7 +9,7 @@ AppsWindow::AppsWindow() : { } -void AppsWindow::setTitle(const char * title) { +void AppsWindow::setTitle(I18n::Message title) { m_titleBarView.setTitle(title); } diff --git a/apps/apps_window.h b/apps/apps_window.h index 0fb96082c..8f4e2cf0e 100644 --- a/apps/apps_window.h +++ b/apps/apps_window.h @@ -7,7 +7,7 @@ class AppsWindow : public Window { public: AppsWindow(); - void setTitle(const char * title); + void setTitle(I18n::Message title); void updateBatteryLevel(); void refreshPreferences(); private: diff --git a/apps/calculation/app.cpp b/apps/calculation/app.cpp index 623b17d42..12966851a 100644 --- a/apps/calculation/app.cpp +++ b/apps/calculation/app.cpp @@ -1,5 +1,6 @@ #include "app.h" #include "calculation_icon.h" +#include "../i18n.h" using namespace Poincare; using namespace Shared; @@ -7,7 +8,7 @@ using namespace Shared; namespace Calculation { App::App(Container * container, Context * context) : - TextFieldDelegateApp(container, &m_editExpressionController, "Calculs", "CALCULS", ImageStore::CalculationIcon), + TextFieldDelegateApp(container, &m_editExpressionController, I18n::Message::CalculApp, I18n::Message::CalculAppCapital, ImageStore::CalculationIcon), m_localContext(LocalContext((GlobalContext *)context, &m_calculationStore)), m_calculationStore(CalculationStore()), m_historyController(HistoryController(&m_editExpressionController, &m_calculationStore)), diff --git a/apps/calculation/edit_expression_controller.cpp b/apps/calculation/edit_expression_controller.cpp index 1825e03f5..b09818fc3 100644 --- a/apps/calculation/edit_expression_controller.cpp +++ b/apps/calculation/edit_expression_controller.cpp @@ -51,10 +51,6 @@ View * EditExpressionController::view() { return &m_contentView; } -const char * EditExpressionController::title() const { - return "EditExpressionController"; -} - const char * EditExpressionController::textBody() { return m_contentView.textField()->text(); } diff --git a/apps/calculation/edit_expression_controller.h b/apps/calculation/edit_expression_controller.h index 42a0e734f..9bdb1cb72 100644 --- a/apps/calculation/edit_expression_controller.h +++ b/apps/calculation/edit_expression_controller.h @@ -14,7 +14,6 @@ class EditExpressionController : public ViewController, public Shared::TextField public: EditExpressionController(Responder * parentResponder, HistoryController * historyController, CalculationStore * calculationStore); View * view() override; - const char * title() const override; void didBecomeFirstResponder() override; bool handleEvent(Ion::Events::Event event) override; const char * textBody(); diff --git a/apps/calculation/history_controller.cpp b/apps/calculation/history_controller.cpp index 1f8ae4cff..0be3ac8b3 100644 --- a/apps/calculation/history_controller.cpp +++ b/apps/calculation/history_controller.cpp @@ -16,10 +16,6 @@ View * HistoryController::HistoryController::view() { return &m_selectableTableView; } -const char * HistoryController::title() const { - return "Calculation Table"; -} - void HistoryController::reload() { m_selectableTableView.reloadData(); } diff --git a/apps/calculation/history_controller.h b/apps/calculation/history_controller.h index 5a58dc975..3ff3a0e12 100644 --- a/apps/calculation/history_controller.h +++ b/apps/calculation/history_controller.h @@ -16,7 +16,6 @@ public: HistoryController(Responder * parentResponder, CalculationStore * calculationStore); View * view() override; - const char * title() const override; bool handleEvent(Ion::Events::Event event) override; void didBecomeFirstResponder() override; void reload(); diff --git a/apps/global_preferences.cpp b/apps/global_preferences.cpp index a68749f40..280f2f9b3 100644 --- a/apps/global_preferences.cpp +++ b/apps/global_preferences.cpp @@ -3,7 +3,7 @@ static GlobalPreferences s_globalPreferences; GlobalPreferences::GlobalPreferences() : - m_language(Language::French) + m_language(I18n::Language::French) { } @@ -11,11 +11,11 @@ GlobalPreferences * GlobalPreferences::sharedGlobalPreferences() { return &s_globalPreferences; } -GlobalPreferences::Language GlobalPreferences::language() const { +I18n::Language GlobalPreferences::language() const { return m_language; } -void GlobalPreferences::setLanguage(Language language) { +void GlobalPreferences::setLanguage(I18n::Language language) { if (language != m_language) { m_language = language; } diff --git a/apps/global_preferences.h b/apps/global_preferences.h index 194aee14d..8bcd8dab5 100644 --- a/apps/global_preferences.h +++ b/apps/global_preferences.h @@ -1,19 +1,16 @@ #ifndef APPS_GLOBAL_PREFERENCES_H #define APPS_GLOBAL_PREFERENCES_H +#include "i18n.h" + class GlobalPreferences { public: - enum class Language { - French = 0, - English = 1, - Spanish = 2 - }; GlobalPreferences(); static GlobalPreferences * sharedGlobalPreferences(); - Language language() const; - void setLanguage(Language language); + I18n::Language language() const; + void setLanguage(I18n::Language language); private: - Language m_language; + I18n::Language m_language; }; #endif diff --git a/apps/graph/app.cpp b/apps/graph/app.cpp index 772bf86d6..4284473bd 100644 --- a/apps/graph/app.cpp +++ b/apps/graph/app.cpp @@ -1,5 +1,6 @@ #include "app.h" #include "graph_icon.h" +#include "../i18n.h" using namespace Poincare; using namespace Shared; @@ -7,7 +8,7 @@ using namespace Shared; namespace Graph { App::App(Container * container, Context * context) : - TextFieldDelegateApp(container, &m_inputViewController, "Fonctions", "FONCTIONS", ImageStore::GraphIcon), + TextFieldDelegateApp(container, &m_inputViewController, I18n::Message::FunctionApp, I18n::Message::FunctionAppCapital, ImageStore::GraphIcon), m_functionStore(CartesianFunctionStore()), m_xContext(VariableContext('x', context)), m_listController(ListController(&m_listFooter, &m_functionStore, &m_listHeader, &m_listFooter)), diff --git a/apps/graph/graph/curve_parameter_controller.cpp b/apps/graph/graph/curve_parameter_controller.cpp index 10d2f18b4..3ec69cb91 100644 --- a/apps/graph/graph/curve_parameter_controller.cpp +++ b/apps/graph/graph/curve_parameter_controller.cpp @@ -6,15 +6,15 @@ using namespace Shared; namespace Graph { CurveParameterController::CurveParameterController(InteractiveCurveViewRange * graphRange, BannerView * bannerView, CurveViewCursor * cursor) : - FunctionCurveParameterController(graphRange, cursor, "x"), + FunctionCurveParameterController(graphRange, cursor, I18n::Message::X), m_bannerView(bannerView), - m_calculationCell(PointerTableCellWithChevron((char*)"Calculer")), - m_derivativeCell(PointerTableCellWithSwitch((char*)"Nombre derivee")) + m_calculationCell(PointerTableCellWithChevron(I18n::Message::Compute)), + m_derivativeCell(PointerTableCellWithSwitch(I18n::Message::DerivateNumber)) { } -const char * CurveParameterController::title() const { - return "Options de la courbe"; +const char * CurveParameterController::title() { + return I18n::translate(I18n::Message::PlotOptions); } void CurveParameterController::willDisplayCellForIndex(HighlightCell * cell, int index) { diff --git a/apps/graph/graph/curve_parameter_controller.h b/apps/graph/graph/curve_parameter_controller.h index 919035e3c..42bc983d1 100644 --- a/apps/graph/graph/curve_parameter_controller.h +++ b/apps/graph/graph/curve_parameter_controller.h @@ -9,7 +9,7 @@ namespace Graph { class CurveParameterController : public Shared::FunctionCurveParameterController { public: CurveParameterController(Shared::InteractiveCurveViewRange * graphRange, BannerView * bannerView, Shared::CurveViewCursor * cursor); - const char * title() const override; + const char * title() override; bool handleEvent(Ion::Events::Event event) override; int numberOfRows() override; HighlightCell * reusableCell(int index) override; diff --git a/apps/graph/graph/graph_controller.cpp b/apps/graph/graph/graph_controller.cpp index 01e730655..61a954c9a 100644 --- a/apps/graph/graph/graph_controller.cpp +++ b/apps/graph/graph/graph_controller.cpp @@ -15,11 +15,11 @@ GraphController::GraphController(Responder * parentResponder, CartesianFunctionS { } -const char * GraphController::emptyMessage() { +I18n::Message GraphController::emptyMessage() { if (m_functionStore->numberOfDefinedFunctions() == 0) { - return "Aucune fonction"; + return I18n::Message::NoFunction; } - return "Aucune fonction activee"; + return I18n::Message::NoActivatedFunction; } BannerView * GraphController::bannerView() { diff --git a/apps/graph/graph/graph_controller.h b/apps/graph/graph/graph_controller.h index 93cf8192a..96dad41f2 100644 --- a/apps/graph/graph/graph_controller.h +++ b/apps/graph/graph/graph_controller.h @@ -12,7 +12,7 @@ namespace Graph { class GraphController : public Shared::FunctionGraphController { public: GraphController(Responder * parentResponder, CartesianFunctionStore * functionStore, ButtonRowController * header); - const char * emptyMessage() override; + I18n::Message emptyMessage() override; private: BannerView * bannerView() override; void reloadBannerView() override; diff --git a/apps/graph/list/list_controller.cpp b/apps/graph/list/list_controller.cpp index cf4600181..2d6728767 100644 --- a/apps/graph/list/list_controller.cpp +++ b/apps/graph/list/list_controller.cpp @@ -1,5 +1,6 @@ #include "list_controller.h" #include "../app.h" +#include "../../i18n.h" #include using namespace Shared; @@ -7,15 +8,15 @@ using namespace Shared; namespace Graph { ListController::ListController(Responder * parentResponder, CartesianFunctionStore * functionStore, ButtonRowController * header, ButtonRowController * footer) : - Shared::ListController(parentResponder, functionStore, header, footer, "Ajouter une fonction"), + Shared::ListController(parentResponder, functionStore, header, footer, I18n::Message::AddFunction), m_functionTitleCells{FunctionTitleCell(FunctionTitleCell::Orientation::VerticalIndicator), FunctionTitleCell(FunctionTitleCell::Orientation::VerticalIndicator), FunctionTitleCell(FunctionTitleCell::Orientation::VerticalIndicator), FunctionTitleCell(FunctionTitleCell::Orientation::VerticalIndicator), FunctionTitleCell(FunctionTitleCell::Orientation::VerticalIndicator)}, - m_parameterController(ListParameterController(this, functionStore)) + m_parameterController(ListParameterController(this, functionStore, I18n::Message::FunctionColor, I18n::Message::DeleteFunction)) { } -const char * ListController::title() const { - return "Fonctions"; +const char * ListController::title() { + return I18n::translate(I18n::Message::FunctionTab); } int ListController::numberOfRows() { diff --git a/apps/graph/list/list_controller.h b/apps/graph/list/list_controller.h index c6d6955a4..5f6568a36 100644 --- a/apps/graph/list/list_controller.h +++ b/apps/graph/list/list_controller.h @@ -14,7 +14,7 @@ namespace Graph { class ListController : public Shared::ListController { public: ListController(Responder * parentResponder, CartesianFunctionStore * functionStore, ButtonRowController * header, ButtonRowController * footer); - const char * title() const override; + const char * title() override; int numberOfRows() override; KDCoordinate rowHeight(int j) override; private: diff --git a/apps/graph/values/derivative_parameter_controller.cpp b/apps/graph/values/derivative_parameter_controller.cpp index a2e223cd1..3120ef7a9 100644 --- a/apps/graph/values/derivative_parameter_controller.cpp +++ b/apps/graph/values/derivative_parameter_controller.cpp @@ -6,9 +6,8 @@ namespace Graph { DerivativeParameterController::DerivativeParameterController(ValuesController * valuesController) : ViewController(valuesController), - m_pageTitle{"Colonne f'(x)"}, - m_hideColumn(PointerTableCell((char*)"Masquer la colonne de la derivee")), - m_copyColumn(PointerTableCellWithChevron((char*)"Copier la colonne dans une liste")), + m_hideColumn(PointerTableCell(I18n::Message::HideDerivativeColumn)), + m_copyColumn(PointerTableCellWithChevron(I18n::Message::CopyColumnInList)), m_selectableTableView(SelectableTableView(this, this, 1, Metric::CommonTopMargin, Metric::CommonRightMargin, Metric::CommonBottomMargin, Metric::CommonLeftMargin)), m_function(nullptr), @@ -16,7 +15,14 @@ DerivativeParameterController::DerivativeParameterController(ValuesController * { } -const char * DerivativeParameterController::title() const { +const char * DerivativeParameterController::title() { + strlcpy(m_pageTitle, I18n::translate(I18n::Message::DerivativeColumn), k_maxNumberOfCharsInTitle); + for (int currentChar = 0; currentChar < k_maxNumberOfCharsInTitle; currentChar++) { + if (m_pageTitle[currentChar] == '(') { + m_pageTitle[currentChar-2] = *m_function->name(); + break; + } + } return m_pageTitle; } @@ -26,12 +32,6 @@ View * DerivativeParameterController::view() { void DerivativeParameterController::setFunction(CartesianFunction * function) { m_function = function; - for (int currentChar = 0; currentChar < k_maxNumberOfCharsInTitle; currentChar++) { - if (m_pageTitle[currentChar] == '(') { - m_pageTitle[currentChar-2] = *m_function->name(); - return; - } - } } void DerivativeParameterController::didBecomeFirstResponder() { diff --git a/apps/graph/values/derivative_parameter_controller.h b/apps/graph/values/derivative_parameter_controller.h index 05fe0fee8..2d940bd83 100644 --- a/apps/graph/values/derivative_parameter_controller.h +++ b/apps/graph/values/derivative_parameter_controller.h @@ -13,7 +13,7 @@ public: DerivativeParameterController(ValuesController * valuesController); View * view() override; - const char * title() const override; + const char * title() override; bool handleEvent(Ion::Events::Event event) override; void didBecomeFirstResponder() override; int numberOfRows() override; diff --git a/apps/graph/values/function_parameter_controller.cpp b/apps/graph/values/function_parameter_controller.cpp index 5802e19ff..b2794d9f4 100644 --- a/apps/graph/values/function_parameter_controller.cpp +++ b/apps/graph/values/function_parameter_controller.cpp @@ -8,7 +8,7 @@ namespace Graph { FunctionParameterController::FunctionParameterController(ValuesController * valuesController) : ValuesFunctionParameterController('x'), - m_displayDerivativeColumn(PointerTableCellWithSwitch((char*)"Colonne de la fonction derivee")), + m_displayDerivativeColumn(PointerTableCellWithSwitch(I18n::Message::DerivativeFunctionColumn)), m_cartesianFunction(nullptr), m_valuesController(valuesController) { diff --git a/apps/graph/values/values_controller.cpp b/apps/graph/values/values_controller.cpp index cea06944c..9d83fe7e0 100644 --- a/apps/graph/values/values_controller.cpp +++ b/apps/graph/values/values_controller.cpp @@ -6,7 +6,7 @@ using namespace Shared; namespace Graph { ValuesController::ValuesController(Responder * parentResponder, CartesianFunctionStore * functionStore, ButtonRowController * header) : - Shared::ValuesController(parentResponder, header, 'x'), + Shared::ValuesController(parentResponder, header, I18n::Message::XColumn), m_functionTitleCells{FunctionTitleCell(FunctionTitleCell::Orientation::HorizontalIndicator, KDText::FontSize::Small), FunctionTitleCell(FunctionTitleCell::Orientation::HorizontalIndicator, KDText::FontSize::Small), FunctionTitleCell(FunctionTitleCell::Orientation::HorizontalIndicator, KDText::FontSize::Small), FunctionTitleCell(FunctionTitleCell::Orientation::HorizontalIndicator, KDText::FontSize::Small), FunctionTitleCell(FunctionTitleCell::Orientation::HorizontalIndicator, KDText::FontSize::Small)}, m_functionStore(functionStore), @@ -39,7 +39,7 @@ void ValuesController::willDisplayCellAtLocation(HighlightCell * cell, int i, in // The cell is the abscissa title cell: if (j == 0 && i == 0) { EvenOddPointerTextCell * mytitleCell = (EvenOddPointerTextCell *)cell; - mytitleCell->setText("x"); + mytitleCell->setMessage(I18n::Message::X); return; } // The cell is a function title cell: @@ -61,11 +61,11 @@ void ValuesController::willDisplayCellAtLocation(HighlightCell * cell, int i, in } } -const char * ValuesController::emptyMessage() { +I18n::Message ValuesController::emptyMessage() { if (m_functionStore->numberOfDefinedFunctions() == 0) { - return "Aucune fonction"; + return I18n::Message::NoFunction; } - return "Aucune fonction selectionnee"; + return I18n::Message::NoActivatedFunction; } void ValuesController::selectCellAtLocation(int i, int j) { diff --git a/apps/graph/values/values_controller.h b/apps/graph/values/values_controller.h index e564da59d..baed47da9 100644 --- a/apps/graph/values/values_controller.h +++ b/apps/graph/values/values_controller.h @@ -15,7 +15,7 @@ public: bool handleEvent(Ion::Events::Event event) override; int numberOfColumns() override; void willDisplayCellAtLocation(HighlightCell * cell, int i, int j) override; - const char * emptyMessage() override; + I18n::Message emptyMessage() override; void selectCellAtLocation(int i, int j); int activeRow(); int activeColumn(); diff --git a/apps/home/app.cpp b/apps/home/app.cpp index f4b00cec5..1ac09f50a 100644 --- a/apps/home/app.cpp +++ b/apps/home/app.cpp @@ -1,5 +1,7 @@ #include "app.h" #include "../apps_container.h" +#include "../i18n.h" + extern "C" { #include } @@ -7,7 +9,7 @@ extern "C" { namespace Home { App::App(AppsContainer * container) : - ::App(container, &m_controller, "Applications", "APPLICATIONS"), + ::App(container, &m_controller, I18n::Message::Apps, I18n::Message::AppsCapital, nullptr, I18n::Message::Warning), m_controller(Controller(&m_modalViewController, container)) { assert(container->appAtIndex(0) == this); diff --git a/apps/home/app_cell.cpp b/apps/home/app_cell.cpp index 56dabde27..cee317bb9 100644 --- a/apps/home/app_cell.cpp +++ b/apps/home/app_cell.cpp @@ -5,7 +5,7 @@ namespace Home { AppCell::AppCell() : HighlightCell(), - m_nameView(PointerTextView(KDText::FontSize::Small, nullptr, 0.5f, 0.5f, KDColorBlack, KDColorWhite)), + m_nameView(PointerTextView(KDText::FontSize::Small, (I18n::Message)0, 0.5f, 0.5f, KDColorBlack, KDColorWhite)), m_visible(true) { } @@ -27,7 +27,7 @@ void AppCell::layoutSubviews() { void AppCell::setApp(::App * app) { m_iconView.setImage(app->icon()); - m_nameView.setText(app->name()); + m_nameView.setMessage(app->name()); layoutSubviews(); } diff --git a/apps/home/controller.cpp b/apps/home/controller.cpp index 6b5fd7840..a6282f6c6 100644 --- a/apps/home/controller.cpp +++ b/apps/home/controller.cpp @@ -31,6 +31,10 @@ void Controller::didBecomeFirstResponder() { app()->setFirstResponder(&m_selectableTableView); } +void Controller::viewWillAppear() { + m_selectableTableView.reloadData(); +} + View * Controller::view() { return &m_selectableTableView; } diff --git a/apps/home/controller.h b/apps/home/controller.h index 5a379bfe6..ea33641ea 100644 --- a/apps/home/controller.h +++ b/apps/home/controller.h @@ -16,6 +16,7 @@ public: bool handleEvent(Ion::Events::Event event) override; void didBecomeFirstResponder() override; + void viewWillAppear() override; virtual int numberOfRows() override; virtual int numberOfColumns() override; diff --git a/apps/i18n.cpp b/apps/i18n.cpp new file mode 100644 index 000000000..a5d571288 --- /dev/null +++ b/apps/i18n.cpp @@ -0,0 +1,359 @@ +#include "i18n.h" +#include "global_preferences.h" +#include + +namespace I18n { + +constexpr static char lambdaExponentialFrenchDefinition[] = {Ion::Charset::SmallLambda, ' ', ':', ' ', 'P', 'a', 'r', 'a', 'm', 'e', 't', 'r', 'e', 0}; +constexpr static char lambdaExponentialEnglishDefinition[] = {Ion::Charset::SmallLambda, ':', ' ', 'R', 'a', 't','e',' ', 'p', 'a', 'r', 'a', 'm', 'e', 't', 'e', 'r', 0}; +constexpr static char lambdaExponentialSpanishDefinition[] = {Ion::Charset::SmallLambda, ' ', ':', ' ', 'P', 'a', 'r', 'a', 'm', 'e', 't', 'r', 'o', 0}; +constexpr static char lambdaPoissonFrenchDefinition[] = {Ion::Charset::SmallLambda, ' ', ':', ' ', 'P', 'a', 'r', 'a', 'm', 'e', 't', 'r', 'e', 0}; +constexpr static char lambdaPoissonEnglishDefinition[] = {Ion::Charset::SmallLambda, ':', ' ', 'P', 'a', 'r', 'a', 'm', 'e', 't', 'e', 'r', 0}; +constexpr static char lambdaPoissonSpanishDefinition[] = {Ion::Charset::SmallLambda, ' ', ':', ' ', 'P', 'a', 'r', 'a', 'm', 'e', 't', 'r', 'o', 0}; +constexpr static char meanFrenchDefinition[] = {Ion::Charset::SmallMu, ' ', ':', ' ', 'M', 'o', 'y', 'e', 'n', 'n', 'e', 0}; +constexpr static char meanEnglishDefinition[] = {Ion::Charset::SmallMu, ':', ' ', 'M', 'e', 'a', 'n', 0}; +constexpr static char meanSpanishDefinition[] = {Ion::Charset::SmallMu, ' ', ':', ' ', 'M', 'e', 'd', 'i', 'a', 0}; +constexpr static char deviationFrenchDefinition[] = {Ion::Charset::SmallSigma, ':', ' ', 'E', 'c', 'a', 'r', 't', '-', 't', 'y', 'p', 'e', 0}; +constexpr static char deviationEnglishDefinition[] = {Ion::Charset::SmallSigma, ' ', ':', ' ', 'S', 't', 'a', 'n', 'd', 'a', 'r', 'd', ' ','d','e', 'v', 'i', 'a', 't','i','o','n', 0}; +constexpr static char deviationSpanishDefinition[] = {Ion::Charset::SmallSigma, ' ', ':', ' ', 'D', 'e','s','v','i','a','c','i','o','n',' ','t','i','p','i','c','a',0}; + +const char * messages[200][3] { + {"Attention", "Warning", "Cuidado"}, + {"Valider", "Confirm", "Confirmar"}, + {"Suivant", "Next", "Siguiente"}, + {"Attention a la syntaxe", "Syntax error", "Error sintactico"}, + {"Error mathematique", "Math error", "Error matematico"}, + + /* Variables */ + {"Variables", "Variables", "Variables"}, + {"Nombres", "Numbers", "Numeros"}, + {"Listes", "Lists", "Listas"}, + {"Matrices", "Matrices", "Matrices"}, + + /* Toolbox */ + {"Toolbox", "Toolbox", "Toolbox"}, + {"Valeur absolue", "Absolute value", "Valor absoluto"}, + {"Racine n-ieme", "nth-root", "Raiz enesima"}, + {"Logarithme base a", "Logarithm to base a", "Logaritmo en base b"}, + {"Calculs", "Calculation", "Calculos"}, + {"Nombres complexes", "Complex numbers", "Numeros complejos"}, + {"Probabilites", "Probability", "Probabilidad"}, + {"Arithmetique", "Arithmetic", "Aritmetica"}, + {"Matrices", "Matrix", "Matriz"}, + {"Listes", "List", "Listas"}, + {"Approximation", "Approximation", "Aproximacion"}, + {"Trigonometrie hyperbolique", "Hyperbolic trigonometry", "Trigonometria hiberbolica"}, + {"Intervalle fluctuation", "Prediction Interval", "Interval de prediccion"}, + {"Nombre derive", "Derivative", "Derivada"}, + {"Integrale", "Integral", "Integral"}, + {"Somme", "Sum", "Suma"}, + {"Produit", "Product", "Productorio"}, + {"Module", "Absolute value", "Modulo"}, + {"Argument", "Argument", "Argumento"}, + {"Partie reelle", "Real part", "Parte real"}, + {"Partie imaginaire", "Imaginary part", "Parte imaginaria"}, + {"Conjugue", "Conjugate", "Conjugado"}, + {"Combinaison", "Combination", "Combinacion"}, + {"Arrangement", "Permutation", "Variacion"}, + {"PGCD", "GCD", "MCD"}, + {"PPCM", "LCM", "MCM"}, + {"Reste division p par q", "Remainder division p by q", "Resto division p por q"}, + {"Quotient division p par q", "Quotient division p by q", "Cociente division p por q"}, + {"Inverse", "Inverse", "Inversa"}, + {"Determinant", "Determinant", "Determinante"}, + {"Transposee", "Transpose", "Transpuesta"}, + {"Trace ", "Trace", "Traza"}, + {"Taille", "Size", "Tamano"}, + {"Tri croissant", "Sort ascending ", "Clasificacion ascendente"}, + {"Tri decroissant", "Sort descending", "Clasificacion descendente"}, + {"Maximum", "Maximum", "Maximo"}, + {"Minimum", "Minimum", "Minimo"}, + {"Partie entiere", "Floor", "Parte entera"}, + {"Partie fractionnaire", "Fractional part", "Parte fraccionaria"}, + {"Plafond", "Ceiling", "Techo"}, + {"Arrondi n chiffres apres la virgule", "Rounding to n digits of precision", "Redondeo n digitos despues de la coma"}, + {"Intervalle fluctuation 95%", "Prediction interval 95%", "Intervalo de prediccion 95%"}, + {"Intervalle fluctuation simple", "Simple prediction interval", "Intervalo de prediciion simple"}, + {"Intervalle confiance", "Confidence interval", "Intervalo de confianza"}, + + /* Applications */ + {"Applications", "Applications", "Aplicacion"}, + {"APPLICATIONS", "APPLICATIONS", "APLICACION"}, + + /* 1.Calculation */ + {"Calculs", "Calculation", "Calculo"}, + {"CALCULS", "CALCULATION", "CALCULO"}, + + /* 2.Function */ + {"Fonctions", "Functions", "Funcion"}, + {"FONCTIONS", "FUNCTIONS", "FUNCION"}, + {"Fonctions", "Functions", "Funciones"}, + {"Graphique", "Graph", "Grafico"}, + {"Valeurs", "Table", "Tabla"}, + /* Function: first tab */ + {"Tracer", "Plot", "Dibujar"}, + {"Afficher les valeurs", "Display values", "Visualizar los valores"}, + {"Options de la fonction", "Function options", "Opciones de la funcion"}, + {"Ajouter une fonction", "Add function", "Agregar una funcion"}, + {"Supprimer la fonction", "Delete function", "Eliminar la funcion"}, + {"Pas de fonction a supprimer", "No function to delete", "Ninguna funcion que eliminar"}, + {"Activer/Desactiver", "Turn on/off", "Activar/Desactivar"}, + {"Couleur de la fonction", "Function color", "Color de la funcion"}, + /* Function: second tab */ + {"Aucune fonction", "No function", "Ninguna funcion"}, + {"Aucune fonction activee", "No function is turned on", "Ninguna funcion activada"}, + {"Axes", "Axes", "Ejes"}, + {"Zoom", "Zoom", "Zoom"}, + {"Zoom interactif", "Interactive zoom", "Zoom interactivo"}, + {"Zoom predefini", "Predefined zoom", "Zoom predefinido"}, + {"Initialisation", "Preadjustment", "Inicializacion"}, + {"HAUT", "TOP", "???"}, + {"GAUCHE", "LEFT", "???"}, + {"BAS", "BOTTM", "???"}, + {"DROITE", "RIGHT", "???"}, + {"ZOOM", "ZOOM", "ZOOM"}, + {"Se deplacer", "Move", "Mover"}, + {"Zoomer", "Zoom", "Zoom"}, + {"Trigonometrique", "Trigonometrical", "Trigonometrico"}, + {"Abscisses entieres", "Integer", "Abscisas enteras"}, + {"Orthonorme", "Orthonormal", "Ortonormal"}, + {"Reglages de base", "Basic settings", "Ajustes basicos"}, + {"Options de la courbe", "Plot options", "Opciones de la curva"}, + {"Calculer", "Calculate", "Calcular"}, + {"Aller a", "Go to", "Ir a"}, + {"Zeros", "Zeros", "Raices"}, + {"Tangente", "Tangent", "Tangente"}, + {"Intersection", "Intersection", "Interseccion"}, + {"Selectionner la borne inferieure", "Select lower bound", "Seleccionar el limite inferior"}, + {"Selectionner la borne superieure", "Select upper bound", "Seleccionar el limite superior"}, + {"Aucun zero trouve", "No zeros found", "Ninguna raiz encontrada"}, + /* Function: third tab*/ + {"Regler l'intervalle", "Set the interval", "Ajustar el intervalo"}, + {"X debut", "X start", "X inicio"}, + {"X fin", "X end", "X fin"}, + {"Pas", "Step", "Incremento"}, + {"Colonne x", "x column", "Columna x"}, + {"Colonne 0(0)", "Function 0(0)", "Columna 0(0)"}, + {"Colonne 0'(x)", "Column 0'(x)", "Columna 0'(x)"}, + {"Colonne de la fonction derivee", "Derivative function column", "Columna de la derivada"}, + {"Effacer la colonne", "Clear column", "Borrar la columna"}, + {"Copier la colonne dans une liste", "Export the column to a list", "Copiar la columna en una lista"}, + {"Masquer la fonction derivee", "Hide the derivative function", "Ocultar la derivada"}, + + /* Sequence */ + {"Suites", "Sequences", "Sucesion"}, + {"SUITES", "SEQUENCES", "SUCESION"}, + {"Suites", "Sequences", "Sucesiones"}, + /* Sequence: first tab */ + {"Ajouter une suite", "Add sequence", "Agregar una sucesion"}, + {"Choisir le type de suite", "Choose sequence type", "Seleccionar el tipo de sucesion"}, + {"Type de suite", "Sequence type", "Tipo de sucesion"}, + {"Explicite", "Explicit expression", "Formula explicita"}, + {"Recurrente d'ordre 1", "Recursive first order", "Recurrencia de orden uno"}, + {"Recurrente d'ordre 2", "Recursive second order", "Recurrencia de orden dos"}, + {"Options de la suite", "Sequence options", "Opciones de sucesion"}, + {"Couleur de la suite", "Sequence color", "Color de la sucesion"}, + {"Supprimer la suite", "Delete sequence", "Eliminar la sucesion"}, + /* Sequence: second tab */ + {"Aucune suite", "No sequence", "Ninguna sucesion"}, + {"Aucune suite activee", "No sequence is turned on", "Ninguna sucesion activada"}, + {"Somme des termes", "Sum of terms", "Suma de terminos"}, + {"SELECTIONNER LE PREMIER TERME", "SELECT FIRST TERM", "SELECCIONAR EL PRIMER TERMINO"}, + {"SELECTIONNER LE DERNIER TERME", "SELECT LAST TERM", "SELECCIONAR ULTIMO TERMINO"}, + /* Sequence: third tab */ + {"Colonne n", "n column", "Columna n"}, + + /* Statistics */ + {"Statistiques", "Statistics", "Estadistica"}, + {"STATISTIQUES", "STATISTICS", "ESTADISTICA"}, + + {"Donnees", "Data", "Datos"}, + {"Histogramme", "Histogram", "Histograma"}, + {"Boite", "Box", "Caja"}, + {"Stats", "Statistics", "Medidas"}, + + /* Statistics: first tab */ + {"Valeurs", "Values", "Valores"}, + {"Effectifs", "Sizes", "Frecuencias"}, + {"Options de la colonne", "Column options", "Opciones de columna"}, + {"Importer une liste", "Import from a list", "Importar una lista"}, + /* Statistics: second tab */ + {"Aucune donnee a tracer", "No data to draw", "Ningunos datos que dibujar"}, + {"Intervalle ", "Interval ", "Intervalo"}, + {"Effectif", "Size", "Frecuencia"}, + {" Frequence", " Frequency", " Frequencia (relativa)"}, + {"Reglage de l'histogramme", "Histogram settings", "Parametros del histograma"}, + {"Largeur des rectangles", "Bin width", "Ancho del rectangulo"}, + {"Debut de la serie", "X start", "Principio de la serie"}, + /* Statistics: third tab */ + {"Premier quartile", "First quartile", "Primer cuartil"}, + {"Mediane", "Median", "Mediana"}, + {"Troisieme quartile", "Third quartile", "Tercer cuartil"}, + /* Statistics: fourth tab */ + {"Aucune grandeur a calculer", "No values to calculate", "Ninguna medida que calcular"}, + {"Effectif total", "Total size", "Poblacion"}, + {"Etendue", "Dispersion", "Rango"}, + {"Moyenne", "Mean", "Media"}, + {"Ecart type", "Standard deviation", "Desviacion tipica"}, + {"Variance", "Variance", "Varianza"}, + {"Ecart interquartile", "Interquartile range", "Rango intercuartilo"}, + {"Somme des carres", "Sum of squares", "Suma de los cuadrados"}, + + /* Probability */ + {"Probabilites", "Probability", "Probabilidad"}, + {"PROBABILITES", "PROBABILITY", "PROBABILIDAD"}, + + {"Choisir le type de loi", "Choose the distribution", "Seleccionar la distribucion"}, + {"Binomiale", "Binomial", "Binomial"}, + {"Uniforme", "Uniform", "Uniforme"}, + {"Exponentielle", "Exponential", "Exponencial"}, + {"Normale", "Normal", "Normal"}, + {"Poisson", "Poisson", "Poisson"}, + + {"Loi binomiale", "Binomial distribution", "Distribucion binomial"}, + {"Loi uniforme", "Uniform distribution", "Distribucion uniforme"}, + {"Loi exponentielle", "Exponential distribution", "Distribucion exponencial"}, + {"Loi normale", "Normal distribution", "Distribucion normal"}, + {"Loi Poisson", "Poisson distribution", "Distribucion Poisson"}, + {"Choisir les parametres", "Choose parameters", "Seleccionar parametros"}, + {"n : Nombre de repetitions", "n: Number of trials", "n : Numero de ensayos "}, + {"p : Probabilite de succes", "p: Success probability", "p : Probabilidad de exito "}, + {"[a,b] : Intervalle", "[a,b]: Interval", "[a,b] : Intervalo"}, + {lambdaExponentialFrenchDefinition, lambdaExponentialEnglishDefinition, lambdaExponentialSpanishDefinition}, + {meanFrenchDefinition, meanEnglishDefinition, meanSpanishDefinition}, + {deviationFrenchDefinition, deviationEnglishDefinition, deviationSpanishDefinition}, {lambdaPoissonFrenchDefinition, lambdaPoissonEnglishDefinition, lambdaPoissonSpanishDefinition}, + + {"Calculer les probabilites", "Calculate probabilities", "Calcular las probabilidades"}, + {"Valeur interdite", "Forbidden value", "Valor prohibido"}, + {"Valeur non definie", "Undefined value", "Valor indefinido"}, + + /* Regression */ + {"Regressions", "Regression", "Regresion"}, + {"REGRESSIONS", "REGRESSION", "REGRESION"}, + + {"Pas assez de donnees pour une regression", "Not enough data for regerssion", "Escasez de datos para la regresion"}, + {"Droite de regression", "Regression line", "Recta de regresion"}, + {"Prediction sachant X", "Prediction given X", "Prediccion dado X"}, + {"Prediction sachant Y", "Prediction given Y", "Prediccion dado Y"}, + {"Valeur non atteinte par la regression", "Value not reached by regression", "No se alcanza este valor"}, + {"Nombre de points", "Number of points", "Numero de puntos"}, + {"Covariance", "Covariance", "Covarianza"}, + + /* Settings */ + {"Parametres", "Settings", "Configuracion"}, + {"PARAMETRES", "SETTINGS", "CONFIGURATION"}, + {"Unite d'angle", "Angle measure", "Medida del angulo"}, + {"Format resultat", "Result format", "Formato resultado"}, + {"Forme complexe", "Complex format", "Formato complejo"}, + {"Langue", "Language", "Idioma"}, + {"Degres ", "Degrees ", "Grados "}, + {"Radians ", "Radians ", "Radianes "}, + {"Auto ", "Auto ", "Auto "}, + {"Scientifique ", "Scientific ", "Cientifico "}, +}; + +const char Sxy[4] = {Ion::Charset::CapitalSigma, 'x', 'y', 0}; +constexpr static char Mu[] = {Ion::Charset::SmallMu, 0}; +constexpr static char Sigma[] = {Ion::Charset::SmallSigma, 0}; +constexpr static char Lambda[] = {Ion::Charset::SmallLambda, 0}; +constexpr static char rightIntegralSecondLegend[] = {Ion::Charset::LessEqual, 'X', ')', '=', 0}; +constexpr static char leftIntegralFirstLegend[] = {'P', '(', 'X', Ion::Charset::LessEqual, 0}; +constexpr static char finiteIntegralLegend[] = {Ion::Charset::LessEqual, 'X', Ion::Charset::LessEqual, 0}; + + +const char * universalMessages[200] { + "", + "x", + "y", + "n", + "p", + Mu, + Sigma, + Lambda, + "a", + "b", + "r", + Sxy, + + "cosh", + "sinh", + "tanh", + "acosh", + "asinh", + "atanh", + + "Xmin", + "Xmax", + "Ymin", + "Ymax", + "Y auto", + + "P(", + rightIntegralSecondLegend, + leftIntegralFirstLegend, + ")=", + finiteIntegralLegend, + + " y=ax+b ", + + "Francais ", + "English ", + "Espanol ", + + /* Toolbox: commands */ + "abs()", + "root(,)", + "log(,)", + "diff(,)", + "int(,,)", + "sum(,,)", + "product(,,)", + "arg()", + "re()", + "im()", + "conj()", + "binomial(,)", + "permute(,)", + "gcd(,)", + "lcm(,)", + "rem(,)", + "quo(,)", + "inverse()", + "det()", + "transpose()", + "trace()", + "dim()", + "sort<()", + "sort>()", + "max()", + "min()", + "floor()", + "frac()", + "ceil()", + "round(,)", + "cosh()", + "sinh()", + "tanh()", + "acosh()", + "asinh()", + "atanh()", + "prediction95(,)", + "prediction(,)", + "confidence(,)", +}; + +const char * translate(Message m, Language l) { + if ((int)m >= 0x8000) { + assert(universalMessages[(int)m - 0X8000] != nullptr); + return universalMessages[(int)m - 0x8000]; + } + int languageIndex = (int)l; + if (l == Language::Default) { + languageIndex = (int) GlobalPreferences::sharedGlobalPreferences()->language(); + } + assert(languageIndex > 0); + assert(messages[(int)m][languageIndex-1] != nullptr); + return messages[(int)m][languageIndex-1]; +} + +} diff --git a/apps/i18n.h b/apps/i18n.h new file mode 100644 index 000000000..5a99dfe57 --- /dev/null +++ b/apps/i18n.h @@ -0,0 +1,315 @@ +#ifndef APPS_I18N_H +#define APPS_I18N_H + +#include + +namespace I18n { + enum class Message : uint16_t { + Warning = 0, + Ok = 1, + Next = 2, + SyntaxError, + MathError, + + /* Variables */ + Variables, + Number, + Matrix, + List, + + /* Toolbox */ + Toolbox, + AbsoluteValue, + NthRoot, + BasedLogarithm, + Calculation, + ComplexNumber, + Probability, + Arithmetic, + Matrices, + Lists, + Approximation, + HyperbolicTrigonometry, + Fluctuation, + DerivateNumber, + Integral, + Sum, + Product, + ComplexAbsoluteValue, + Agument, + ReelPart, + ImaginaryPart, + Conjugate, + Combination, + Permutation, + GreatCommonDivisor, + LeastCommonMultiple, + Remainder, + Quotient, + Inverse, + Determinant, + Transpose, + Trace, + Dimension, + Sort, + InvSort, + Maximum, + Minimum, + Floor, + FracPart, + Ceiling, + Rounding, + Prediction95, + Prediction, + Confidence, + + /* Applications */ + Apps, + AppsCapital, + + /* Calculation */ + CalculApp, + CalculAppCapital, + + /* Fonction */ + FunctionApp, + FunctionAppCapital, + FunctionTab, + GraphTab, + ValuesTab, + Plot, + DisplayValues, + FunctionOptions, + AddFunction, + DeleteFunction, + NoFunctionToDelete, + ActivateDesactivate, + FunctionColor, + NoFunction, + NoActivatedFunction, + Axis, + Zoom, + InteractiveZoom, + PredefinedZoom, + Initialization, + TopCapital, + LeftCapital, + BottomCapital, + RightCapital, + ZoomCapital, + Move, + ToZoom, + Trigonometric, + RoundAbscissa, + Orthonormal, + DefaultSetting, + PlotOptions, + Compute, + Goto, + Zeros, + Tangent, + Intersection, + SelectLowerBound, + SelectUpperBound, + NoZeroFound, + IntervalSet, + XStart, + XEnd, + XStep, + XColumn, + FunctionColumn, + DerivativeColumn, + DerivativeFunctionColumn, + ClearColumn, + CopyColumnInList, + HideDerivativeColumn, + + /* Sequence */ + SequenceApp, + SequenceAppCapital, + SequenceTab, + AddSequence, + ChooseSequenceType, + SequenceType, + Explicite, + SingleRecurrence, + DoubleRecurrence, + SequenceOptions, + SequenceColor, + DeleteSequence, + NoSequence, + NoActivatedSequence, + TermSum, + SelectFirstTerm, + SelectLastTerm, + NColumn, + + /* Statistics */ + StatsApp, + StatsAppCapital, + DataTab, + HistogramTab, + BoxTab, + StatTab, + Values, + Sizes, + ColumnOptions, + ImportList, + NoDataToPlot, + Interval, + Size, + Frequency, + HistogramSet, + RectangleWidth, + BarStart, + FirstQuartile, + Median, + ThirdQuartile, + NoValueToCompute, + TotalSize, + Range, + Mean, + StandardDeviation, + Deviation, + InterquartileRange, + SquareSum, + + /* Probability */ + ProbaApp, + ProbaAppCapital, + ChooseLaw, + Binomial, + Uniforme, + Exponential, + Normal, + Poisson, + BinomialLaw, + UniformLaw, + ExponentialLaw, + NormalLaw, + PoissonLaw, + ChooseParameters, + RepetitionNumber, + SuccessProbability, + IntervalDefinition, + LambdaExponentialDefinition, + MeanDefinition, + DeviationDefinition, + LambdaPoissonDefinition, + ComputeProbability, + ForbiddenValue, + UndefinedValue, + + /* Regression */ + RegressionApp, + RegressionAppCapital, + NoEnoughDataForRegression, + RegressionSlope, + XPrediction, + YPrediction, + ValueNotReachedByRegression, + NumberOfDots, + Covariance, + + /* Settings */ + SettingsApp, + SettingsAppCapital, + AngleUnit, + DisplayMode, + ComplexFormat, + Language, + Degres, + Radian, + Auto, + Scientific, + + /* UNIVERSAL MESSAGES */ + Default = 0x8000, + X, + Y, + N, + P, + Mu, + Sigma, + Lambda, + A, + B, + R, + Sxy, + + Cosh, + Sinh, + Tanh, + Acosh, + Asinh, + Atanh, + + XMin, + XMax, + YMin, + YMax, + YAuto, + + RightIntegralFirstLegend, + RightIntegralSecondLegend, + LeftIntegralFirstLegend, + LeftIntegralSecondLegend, + FiniteIntegralLegend, + + RegressionFormula, + + French, + English, + Spanish, + + /* Toolbox: commands */ + AbsCommand, + RootCommand, + LogCommand, + DiffCommand, + IntCommand, + SumCommand, + ProductCommand, + ArgCommand, + ReCommand, + ImCommand, + ConjCommand, + BinomialCommand, + PermuteCommand, + GcdCommand, + LcmCommand, + RemCommand, + QuoCommand, + InverseCommand, + DeterminantCommand, + TransposeCommand, + TraceCommand, + DimensionCommand, + SortCommand, + InvSortCommand, + MaxCommand, + MinCommand, + FloorCommand, + FracCommand, + CeilCommand, + RoundCommand, + CoshCommand, + SinhCommand, + TanhCommand, + AcoshCommand, + AsinhCommand, + AtanhCommand, + Prediction95Command, + PredictionCommand, + ConfidenceCommand, + }; + enum class Language : uint16_t { + Default = 0, + French = 1, + English = 2, + Spanish = 3 + }; +} + +#endif + diff --git a/apps/math_toolbox.cpp b/apps/math_toolbox.cpp index c2177b6b5..3e8c88ddf 100644 --- a/apps/math_toolbox.cpp +++ b/apps/math_toolbox.cpp @@ -5,25 +5,25 @@ /* TODO: find a shorter way to initiate tree models * We create one model tree: each node keeps the label of the row it refers to * and the text which would be edited by clicking on the row. When the node is a - * subtree, the edited text is set at nullptr. */ + * subtree, the edited text is set at I18n::Message::Default. */ -const ToolboxNode calculChildren[4] = {ToolboxNode("diff(,)", "Nombre derive"), ToolboxNode("int(,,)", "Integrale"), ToolboxNode("sum(,,)", "Somme"), ToolboxNode("product(,,)", "Produit")}; -const ToolboxNode complexChildren[5] = {ToolboxNode("abs()", "Module"), ToolboxNode("arg()", "Argument"), ToolboxNode("re()", "Partie reelle"), ToolboxNode("im()", "Partie imaginaire"), ToolboxNode("conj()", "Conjugue")}; -const ToolboxNode probabilityChildren[2] = {ToolboxNode("binomial(,)", "Combinaison"), ToolboxNode("permute(,)", "Arrangement")}; -const ToolboxNode arithmeticChildren[4] = {ToolboxNode("gcd(,)", "PGCD"), ToolboxNode("lcm(,)", "PPCM"), ToolboxNode("rem(,)", "Reste division euclidienne"), ToolboxNode("quo(,)","Quotien division euclidienne")}; -const ToolboxNode matricesChildren[5] = {ToolboxNode("inverse()", "Inverse"), ToolboxNode("det()", "Determinant"), ToolboxNode("transpose()", "Transposee"), ToolboxNode("trace()", "Trace"), ToolboxNode("dim()", "Taille")}; -const ToolboxNode listesChildren[5] = {ToolboxNode("sort<()", "Tri croissant"), ToolboxNode("sort>()", "Tri decroissant"), ToolboxNode("max()", "Maximum"), ToolboxNode("min()", "Minimum"), ToolboxNode("dim()", "Taille")}; -const ToolboxNode approximationChildren[4] = {ToolboxNode("floor()", "Partie entiere"), ToolboxNode("frac()", "Partie fractionnaire"), ToolboxNode("ceil()", "Plafond"), ToolboxNode("round(,)", "Arrondi")}; -const ToolboxNode trigonometryChildren[6] = {ToolboxNode("cosh()", "cosh"), ToolboxNode("sinh()", "sinh"), ToolboxNode("tanh()", "tanh"), ToolboxNode("acosh()", "acosh"), ToolboxNode("asinh()", "asinh"), ToolboxNode("atanh()", "atanh")}; -const ToolboxNode predictionChildren[3] = {ToolboxNode("prediction95(,)", "Intervalle fluctuation 95%"), ToolboxNode("prediction(,)", "Intervalle fluctuation simple"), ToolboxNode("confidence(,)", "Intervalle de confiance")}; +const ToolboxNode calculChildren[4] = {ToolboxNode(I18n::Message::DiffCommand, I18n::Message::DerivateNumber), ToolboxNode(I18n::Message::IntCommand, I18n::Message::Integral), ToolboxNode(I18n::Message::SumCommand, I18n::Message::Sum), ToolboxNode(I18n::Message::ProductCommand, I18n::Message::Product)}; +const ToolboxNode complexChildren[5] = {ToolboxNode(I18n::Message::AbsCommand, I18n::Message::ComplexAbsoluteValue), ToolboxNode(I18n::Message::ArgCommand, I18n::Message::Agument), ToolboxNode(I18n::Message::ReCommand, I18n::Message::ReelPart), ToolboxNode(I18n::Message::ImCommand, I18n::Message::ImaginaryPart), ToolboxNode(I18n::Message::ConjCommand, I18n::Message::Conjugate)}; +const ToolboxNode probabilityChildren[2] = {ToolboxNode(I18n::Message::BinomialCommand, I18n::Message::Combination), ToolboxNode(I18n::Message::PermuteCommand, I18n::Message::Permutation)}; +const ToolboxNode arithmeticChildren[4] = {ToolboxNode(I18n::Message::GcdCommand, I18n::Message::GreatCommonDivisor),ToolboxNode(I18n::Message::LcmCommand, I18n::Message::LeastCommonMultiple), ToolboxNode(I18n::Message::RemCommand, I18n::Message::Remainder), ToolboxNode(I18n::Message::QuoCommand, I18n::Message::Quotient)}; +const ToolboxNode matricesChildren[5] = {ToolboxNode(I18n::Message::InverseCommand, I18n::Message::Inverse), ToolboxNode(I18n::Message::DeterminantCommand, I18n::Message::Determinant), ToolboxNode(I18n::Message::TransposeCommand, I18n::Message::Transpose), ToolboxNode(I18n::Message::TraceCommand, I18n::Message::Trace), ToolboxNode(I18n::Message::DimensionCommand, I18n::Message::Dimension)}; +const ToolboxNode listesChildren[5] = {ToolboxNode(I18n::Message::SortCommand, I18n::Message::Sort), ToolboxNode(I18n::Message::InvSortCommand, I18n::Message::InvSort), ToolboxNode(I18n::Message::MaxCommand, I18n::Message::Maximum), ToolboxNode(I18n::Message::MinCommand, I18n::Message::Minimum), ToolboxNode(I18n::Message::DimensionCommand, I18n::Message::Dimension)}; +const ToolboxNode approximationChildren[4] = {ToolboxNode(I18n::Message::FloorCommand, I18n::Message::Floor), ToolboxNode(I18n::Message::FracCommand, I18n::Message::FracPart), ToolboxNode(I18n::Message::CeilCommand, I18n::Message::Ceiling), ToolboxNode(I18n::Message::RoundCommand, I18n::Message::Rounding)}; +const ToolboxNode trigonometryChildren[6] = {ToolboxNode(I18n::Message::CoshCommand, I18n::Message::Cosh), ToolboxNode(I18n::Message::SinhCommand, I18n::Message::Sinh), ToolboxNode(I18n::Message::TanhCommand, I18n::Message::Tanh), ToolboxNode(I18n::Message::AcoshCommand, I18n::Message::Acosh), ToolboxNode(I18n::Message::AsinhCommand, I18n::Message::Asinh), ToolboxNode(I18n::Message::AtanhCommand, I18n::Message::Atanh)}; +const ToolboxNode predictionChildren[3] = {ToolboxNode(I18n::Message::Prediction95Command, I18n::Message::Prediction95), ToolboxNode(I18n::Message::PredictionCommand, I18n::Message::Prediction), ToolboxNode(I18n::Message::ConfidenceCommand, I18n::Message::Confidence)}; -const ToolboxNode menu[12] = {ToolboxNode("abs()", "Valeur absolue"), ToolboxNode("root(,)", "Racine k-ieme"), ToolboxNode("log(,)", "Logarithme base a"), - ToolboxNode("Calcul", nullptr, calculChildren, 4), ToolboxNode("Nombre complexe", nullptr, complexChildren, 5), - ToolboxNode("Probabilite", nullptr, probabilityChildren, 2), ToolboxNode("Arithmetique", nullptr, arithmeticChildren, 4), - ToolboxNode("Matrice", nullptr, matricesChildren, 5), ToolboxNode("Liste", nullptr, listesChildren, 5), - ToolboxNode("Approximation", nullptr, approximationChildren, 4), ToolboxNode("Trigonometrie hyperbolique", nullptr, trigonometryChildren, 6), - ToolboxNode("Intervalle fluctuation", nullptr, predictionChildren, 3)}; -const ToolboxNode toolboxModel = ToolboxNode("Toolbox", nullptr, menu, 12); +const ToolboxNode menu[12] = {ToolboxNode(I18n::Message::AbsCommand, I18n::Message::AbsoluteValue), ToolboxNode(I18n::Message::RootCommand, I18n::Message::NthRoot), ToolboxNode(I18n::Message::LogCommand, I18n::Message::BasedLogarithm), + ToolboxNode(I18n::Message::Calculation, I18n::Message::Default, calculChildren, 4), ToolboxNode(I18n::Message::ComplexNumber, I18n::Message::Default, complexChildren, 5), + ToolboxNode(I18n::Message::Probability, I18n::Message::Default, probabilityChildren, 2), ToolboxNode(I18n::Message::Arithmetic, I18n::Message::Default, arithmeticChildren, 4), + ToolboxNode(I18n::Message::Matrices, I18n::Message::Default, matricesChildren, 5), ToolboxNode(I18n::Message::Lists, I18n::Message::Default, listesChildren, 5), + ToolboxNode(I18n::Message::Approximation, I18n::Message::Default, approximationChildren, 4), ToolboxNode(I18n::Message::HyperbolicTrigonometry, I18n::Message::Default, trigonometryChildren, 6), + ToolboxNode(I18n::Message::Fluctuation, I18n::Message::Default, predictionChildren, 3)}; +const ToolboxNode toolboxModel = ToolboxNode(I18n::Message::Toolbox, I18n::Message::Default, menu, 12); /* State */ @@ -98,8 +98,8 @@ View * MathToolbox::ListController::view() { return m_selectableTableView; } -const char * MathToolbox::ListController::title() const { - return toolboxModel.label(); +const char * MathToolbox::ListController::title() { + return I18n::translate(toolboxModel.label()); } void MathToolbox::ListController::didBecomeFirstResponder() { @@ -155,13 +155,13 @@ void MathToolbox::willDisplayCellForIndex(HighlightCell * cell, int index) { ToolboxNode * node = (ToolboxNode *)m_nodeModel->children(index); if (node->numberOfChildren() == 0) { PointerTableCellWithPointer * myCell = (PointerTableCellWithPointer *)cell; - myCell->setText(node->label()); - myCell->setAccessoryText(node->text()); + myCell->setMessage(node->label()); + myCell->setAccessoryMessage(node->text()); myCell->setAccessoryTextColor(Palette::GreyDark); return; } PointerTableCell * myCell = (PointerTableCell *)cell; - myCell->setText(node->label()); + myCell->setMessage(node->label()); } KDCoordinate MathToolbox::rowHeight(int j) { @@ -237,7 +237,7 @@ const ToolboxNode * MathToolbox::rootModel() { bool MathToolbox::selectLeaf(ToolboxNode * selectedNode){ m_selectableTableView.deselectTable(); ToolboxNode * node = selectedNode; - const char * editedText = node->label(); + const char * editedText = I18n::translate(node->label()); if (!sender()->isEditing()) { sender()->setEditing(true); } diff --git a/apps/math_toolbox.h b/apps/math_toolbox.h index be8bf2875..6e244cf96 100644 --- a/apps/math_toolbox.h +++ b/apps/math_toolbox.h @@ -56,7 +56,7 @@ private: class ListController : public ViewController { public: ListController(Responder * parentResponder, SelectableTableView * tableView); - const char * title() const override; + const char * title() override; View * view() override; void didBecomeFirstResponder() override; void setFirstSelectedRow(int firstSelectedRow); diff --git a/apps/node.cpp b/apps/node.cpp index 332d87e14..7d8ccf5cd 100644 --- a/apps/node.cpp +++ b/apps/node.cpp @@ -4,10 +4,10 @@ int Node::numberOfChildren() const { return m_numberOfChildren; } -const char * Node::label() const { +I18n::Message Node::label() const { return m_label; } bool Node::isNull() const { - return (m_label == nullptr); + return (m_label == I18n::Message::Default); } diff --git a/apps/node.h b/apps/node.h index 0c6394c3b..cfee895f5 100644 --- a/apps/node.h +++ b/apps/node.h @@ -1,19 +1,21 @@ #ifndef APPS_NODE_H #define APPS_NODE_H +#include "i18n.h" + class Node { public: - constexpr Node(const char * label = nullptr, int numberOfChildren = 0) : + constexpr Node(I18n::Message label = I18n::Message::Default, int numberOfChildren = 0) : m_label(label), m_numberOfChildren(numberOfChildren) { }; virtual const Node * children(int index) const = 0; - const char * label() const; + I18n::Message label() const; int numberOfChildren() const; bool isNull() const; protected: - const char * m_label; + I18n::Message m_label; int m_numberOfChildren; }; diff --git a/apps/picview/picview_controller.cpp b/apps/picview/picview_controller.cpp index 19025e444..b4c6610ea 100644 --- a/apps/picview/picview_controller.cpp +++ b/apps/picview/picview_controller.cpp @@ -12,7 +12,7 @@ View * PicViewController::view() { /* -const char * PicViewController::title() const { +const char * PicViewController::title() { return "PicView"; } */ diff --git a/apps/probability/app.cpp b/apps/probability/app.cpp index e831ad3b8..348db808d 100644 --- a/apps/probability/app.cpp +++ b/apps/probability/app.cpp @@ -6,10 +6,10 @@ using namespace Shared; namespace Probability { App::App(Container * container) : - TextFieldDelegateApp(container, &m_stackViewController, "Probabilites", "PROBABILITES", ImageStore::ProbabilityIcon), + TextFieldDelegateApp(container, &m_stackViewController, I18n::Message::ProbaApp, I18n::Message::ProbaAppCapital, ImageStore::ProbabilityIcon), m_lawController(LawController(nullptr)), m_stackViewController(&m_modalViewController, &m_lawController) { } -} \ No newline at end of file +} diff --git a/apps/probability/calculation/calculation.h b/apps/probability/calculation/calculation.h index 30f73e62e..e08ff6566 100644 --- a/apps/probability/calculation/calculation.h +++ b/apps/probability/calculation/calculation.h @@ -17,7 +17,7 @@ public: virtual Type type() = 0; void setLaw(Law * law); virtual int numberOfParameters() = 0; - virtual const char * legendForParameterAtIndex(int index) = 0; + virtual I18n::Message legendForParameterAtIndex(int index) = 0; virtual void setParameterAtIndex(float f, int index) = 0; virtual float parameterAtIndex(int index) = 0; virtual float lowerBound(); diff --git a/apps/probability/calculation/finite_integral_calculation.cpp b/apps/probability/calculation/finite_integral_calculation.cpp index d698139fd..1f7e3779e 100644 --- a/apps/probability/calculation/finite_integral_calculation.cpp +++ b/apps/probability/calculation/finite_integral_calculation.cpp @@ -22,16 +22,15 @@ int FiniteIntegralCalculation::numberOfParameters() { return 3; } -const char * FiniteIntegralCalculation::legendForParameterAtIndex(int index) { +I18n::Message FiniteIntegralCalculation::legendForParameterAtIndex(int index) { assert(index >= 0 && index < 3); if (index == 0) { - return "P("; + return I18n::Message::RightIntegralFirstLegend; } if (index == 1) { - constexpr static char comparison[] = {Ion::Charset::LessEqual, 'X', Ion::Charset::LessEqual, 0}; - return comparison; + return I18n::Message::FiniteIntegralLegend; } - return ")="; + return I18n::Message::LeftIntegralSecondLegend; } void FiniteIntegralCalculation::setParameterAtIndex(float f, int index) { diff --git a/apps/probability/calculation/finite_integral_calculation.h b/apps/probability/calculation/finite_integral_calculation.h index 7f6f81da3..9498b1a8d 100644 --- a/apps/probability/calculation/finite_integral_calculation.h +++ b/apps/probability/calculation/finite_integral_calculation.h @@ -11,7 +11,7 @@ public: ~FiniteIntegralCalculation() override {}; Type type() override; int numberOfParameters() override; - const char * legendForParameterAtIndex(int index) override; + I18n::Message legendForParameterAtIndex(int index) override; void setParameterAtIndex(float f, int index) override; float parameterAtIndex(int index) override; float lowerBound() override; diff --git a/apps/probability/calculation/left_integral_calculation.cpp b/apps/probability/calculation/left_integral_calculation.cpp index 7a7f1e4e6..2b53da9e2 100644 --- a/apps/probability/calculation/left_integral_calculation.cpp +++ b/apps/probability/calculation/left_integral_calculation.cpp @@ -21,13 +21,12 @@ int LeftIntegralCalculation::numberOfParameters() { return 2; } -const char * LeftIntegralCalculation::legendForParameterAtIndex(int index) { +I18n::Message LeftIntegralCalculation::legendForParameterAtIndex(int index) { assert(index >= 0 && index < 2); if (index == 0) { - constexpr static char comparison[] = {'P', '(', 'X', Ion::Charset::LessEqual, 0}; - return comparison; + return I18n::Message::LeftIntegralFirstLegend; } - return ")="; + return I18n::Message::LeftIntegralSecondLegend; } void LeftIntegralCalculation::setParameterAtIndex(float f, int index) { diff --git a/apps/probability/calculation/left_integral_calculation.h b/apps/probability/calculation/left_integral_calculation.h index 952a20f92..2db028832 100644 --- a/apps/probability/calculation/left_integral_calculation.h +++ b/apps/probability/calculation/left_integral_calculation.h @@ -11,7 +11,7 @@ public: ~LeftIntegralCalculation() override {}; Type type() override; int numberOfParameters() override; - const char * legendForParameterAtIndex(int index) override; + I18n::Message legendForParameterAtIndex(int index) override; void setParameterAtIndex(float f, int index) override; float parameterAtIndex(int index) override; float upperBound() override; diff --git a/apps/probability/calculation/right_integral_calculation.cpp b/apps/probability/calculation/right_integral_calculation.cpp index 216a543fc..7878e98c5 100644 --- a/apps/probability/calculation/right_integral_calculation.cpp +++ b/apps/probability/calculation/right_integral_calculation.cpp @@ -21,13 +21,12 @@ int RightIntegralCalculation::numberOfParameters() { return 2; } -const char * RightIntegralCalculation::legendForParameterAtIndex(int index) { +I18n::Message RightIntegralCalculation::legendForParameterAtIndex(int index) { assert(index >= 0 && index < 2); if (index == 0) { - return "P("; + return I18n::Message::RightIntegralFirstLegend; } - constexpr static char comparison[] = {Ion::Charset::LessEqual, 'X', ')', '=', 0}; - return comparison; + return I18n::Message::RightIntegralSecondLegend; } void RightIntegralCalculation::setParameterAtIndex(float f, int index) { diff --git a/apps/probability/calculation/right_integral_calculation.h b/apps/probability/calculation/right_integral_calculation.h index 4fc4d30ac..095d63075 100644 --- a/apps/probability/calculation/right_integral_calculation.h +++ b/apps/probability/calculation/right_integral_calculation.h @@ -11,7 +11,7 @@ public: ~RightIntegralCalculation() override {}; Type type() override; int numberOfParameters() override; - const char * legendForParameterAtIndex(int index) override; + I18n::Message legendForParameterAtIndex(int index) override; void setParameterAtIndex(float f, int index) override; float parameterAtIndex(int index) override; float lowerBound() override; diff --git a/apps/probability/calculation_controller.cpp b/apps/probability/calculation_controller.cpp index d545cc415..8a64592fe 100644 --- a/apps/probability/calculation_controller.cpp +++ b/apps/probability/calculation_controller.cpp @@ -12,7 +12,7 @@ using namespace Shared; namespace Probability { CalculationController::ContentView::ContentView(Responder * parentResponder, CalculationController * calculationController, Calculation * calculation) : - m_titleView(PointerTextView(KDText::FontSize::Small, "Calculer les probabilites", 0.5f, 0.5f, Palette::GreyDark, Palette::WallScreen)), + m_titleView(PointerTextView(KDText::FontSize::Small, I18n::Message::ComputeProbability, 0.5f, 0.5f, Palette::GreyDark, Palette::WallScreen)), m_lawCurveView(LawCurveView()), m_imageTableView(ImageTableView(parentResponder, calculation, calculationController)), m_calculationCell{EditableTextCell(parentResponder, calculationController, m_draftTextBuffer), @@ -48,17 +48,17 @@ View * CalculationController::ContentView::subviewAtIndex(int index) { return &m_imageTableView; } if (index == 3) { - m_text[0].setText(m_calculation->legendForParameterAtIndex(0)); + m_text[0].setMessage(m_calculation->legendForParameterAtIndex(0)); m_text[0].setAlignment(0.5f, 0.5f); return &m_text[0]; } if (index == 5) { - m_text[1].setText(m_calculation->legendForParameterAtIndex(1)); + m_text[1].setMessage(m_calculation->legendForParameterAtIndex(1)); m_text[1].setAlignment(0.5f, 0.5f); return &m_text[1]; } if (index == 7) { - m_text[2].setText(m_calculation->legendForParameterAtIndex(2)); + m_text[2].setMessage(m_calculation->legendForParameterAtIndex(2)); m_text[2].setAlignment(0.5f, 0.5f); return &m_text[2]; } @@ -83,18 +83,18 @@ void CalculationController::ContentView::layoutSubviews() { m_lawCurveView.setFrame(KDRect(0, titleHeight+ImageTableView::k_imageHeight, bounds().width(), bounds().height() - ImageTableView::k_imageHeight-titleHeight)); m_imageTableView.setFrame(KDRect(xCoordinate, titleHeight, ImageTableView::k_imageWidth, 3*ImageTableView::k_imageHeight)); xCoordinate += ImageTableView::k_imageWidth + k_textWidthMargin; - KDCoordinate numberOfCharacters = strlen(m_calculation->legendForParameterAtIndex(0)); + KDCoordinate numberOfCharacters = strlen(I18n::translate(m_calculation->legendForParameterAtIndex(0))); m_text[0].setFrame(KDRect(xCoordinate, titleHeight, numberOfCharacters*charSize.width(), ImageTableView::k_imageHeight)); xCoordinate += numberOfCharacters*charSize.width() + k_textWidthMargin; m_calculationCell[0].setFrame(KDRect(xCoordinate, titleHeight, k_textFieldWidth, ImageTableView::k_imageHeight)); xCoordinate += k_textFieldWidth + k_textWidthMargin; - numberOfCharacters = strlen(m_calculation->legendForParameterAtIndex(1)); + numberOfCharacters = strlen(I18n::translate(m_calculation->legendForParameterAtIndex(1))); m_text[1].setFrame(KDRect(xCoordinate, titleHeight, numberOfCharacters*charSize.width(), ImageTableView::k_imageHeight)); xCoordinate += numberOfCharacters*charSize.width() + k_textWidthMargin; m_calculationCell[1].setFrame(KDRect(xCoordinate, titleHeight, k_textFieldWidth, ImageTableView::k_imageHeight)); xCoordinate += k_textFieldWidth + k_textWidthMargin; if (m_calculation->numberOfParameters() > 2) { - numberOfCharacters = strlen(m_calculation->legendForParameterAtIndex(2));; + numberOfCharacters = strlen(I18n::translate(m_calculation->legendForParameterAtIndex(2)));; m_text[2].setFrame(KDRect(xCoordinate, titleHeight, numberOfCharacters*charSize.width(), ImageTableView::k_imageHeight)); xCoordinate += numberOfCharacters*charSize.width() + k_textWidthMargin; m_calculationCell[2].setFrame(KDRect(xCoordinate, titleHeight, k_textFieldWidth, ImageTableView::k_imageHeight)); @@ -133,7 +133,7 @@ View * CalculationController::view() { return &m_contentView; } -const char * CalculationController::title() const { +const char * CalculationController::title() { return m_titleBuffer; } @@ -243,7 +243,7 @@ void CalculationController::selectSubview(int subviewIndex) { void CalculationController::updateTitle() { int currentChar = 0; for (int index = 0; index < m_law->numberOfParameter(); index++) { - m_titleBuffer[currentChar++] = m_law->parameterNameAtIndex(index)[0]; + m_titleBuffer[currentChar++] = I18n::translate(m_law->parameterNameAtIndex(index))[0]; strlcpy(m_titleBuffer+currentChar, " = ", 4); currentChar += 3; char buffer[Complex::bufferSizeForFloatsWithPrecision(Constant::ShortNumberOfSignificantDigits)]; diff --git a/apps/probability/calculation_controller.h b/apps/probability/calculation_controller.h index 2b813dd45..04d15fac9 100644 --- a/apps/probability/calculation_controller.h +++ b/apps/probability/calculation_controller.h @@ -14,7 +14,7 @@ class CalculationController : public ViewController, public Shared::TextFieldDel public: CalculationController(Responder * parentResponder); View * view() override; - const char * title() const override; + const char * title() override; void reload(); void setLaw(Law * law); void setCalculationAccordingToIndex(int index); diff --git a/apps/probability/cell.cpp b/apps/probability/cell.cpp index 63afdb65d..88168c1c5 100644 --- a/apps/probability/cell.cpp +++ b/apps/probability/cell.cpp @@ -5,7 +5,7 @@ namespace Probability { Cell::Cell() : HighlightCell(), - m_labelView(PointerTextView(KDText::FontSize::Large, nullptr, 0, 0.5, KDColorBlack, KDColorWhite)) + m_labelView(PointerTextView(KDText::FontSize::Large, (I18n::Message)0, 0, 0.5, KDColorBlack, KDColorWhite)) { } @@ -43,8 +43,8 @@ void Cell::reloadCell() { } } -void Cell::setLabel(const char * text) { - m_labelView.setText(text); +void Cell::setLabel(I18n::Message message) { + m_labelView.setMessage(message); } void Cell::setImage(const Image * image, const Image * focusedImage) { diff --git a/apps/probability/cell.h b/apps/probability/cell.h index 91bf597fe..bdf910e1d 100644 --- a/apps/probability/cell.h +++ b/apps/probability/cell.h @@ -9,7 +9,7 @@ class Cell : public HighlightCell { public: Cell(); void reloadCell() override; - void setLabel(const char * text); + void setLabel(I18n::Message message); void setImage(const Image * image, const Image * focusedImage); void drawRect(KDContext * ctx, KDRect rect) const override; private: diff --git a/apps/probability/law/binomial_law.cpp b/apps/probability/law/binomial_law.cpp index 5e02b1096..1204f5c92 100644 --- a/apps/probability/law/binomial_law.cpp +++ b/apps/probability/law/binomial_law.cpp @@ -9,8 +9,8 @@ BinomialLaw::BinomialLaw() : { } -const char * BinomialLaw::title() { - return "Loi binomiale"; +I18n::Message BinomialLaw::title() { + return I18n::Message::BinomialLaw; } Law::Type BinomialLaw::type() const { @@ -21,21 +21,21 @@ bool BinomialLaw::isContinuous() const { return false; } -const char * BinomialLaw::parameterNameAtIndex(int index) { +I18n::Message BinomialLaw::parameterNameAtIndex(int index) { assert(index >= 0 && index < 2); if (index == 0) { - return "n"; + return I18n::Message::N; } else { - return "p"; + return I18n::Message::P; } } -const char * BinomialLaw::parameterDefinitionAtIndex(int index) { +I18n::Message BinomialLaw::parameterDefinitionAtIndex(int index) { assert(index >= 0 && index < 2); if (index == 0) { - return "n : nombre de repetitions"; + return I18n::Message::RepetitionNumber; } else { - return "p : probabilites de succes"; + return I18n::Message::SuccessProbability; } } diff --git a/apps/probability/law/binomial_law.h b/apps/probability/law/binomial_law.h index 85b1514d6..344881ee3 100644 --- a/apps/probability/law/binomial_law.h +++ b/apps/probability/law/binomial_law.h @@ -9,15 +9,15 @@ class BinomialLaw : public TwoParameterLaw { public: BinomialLaw(); ~BinomialLaw() override {}; - const char * title() override; + I18n::Message title() override; Type type() const override; bool isContinuous() const override; float xMin() override; float yMin() override; float xMax() override; float yMax() override; - const char * parameterNameAtIndex(int index) override; - const char * parameterDefinitionAtIndex(int index) override; + I18n::Message parameterNameAtIndex(int index) override; + I18n::Message parameterDefinitionAtIndex(int index) override; float evaluateAtAbscissa(float x) const override; bool authorizedValueAtIndex(float x, int index) const override; float cumulativeDistributiveInverseForProbability(float * probability) override; diff --git a/apps/probability/law/exponential_law.cpp b/apps/probability/law/exponential_law.cpp index 97645a626..b7de0df73 100644 --- a/apps/probability/law/exponential_law.cpp +++ b/apps/probability/law/exponential_law.cpp @@ -11,8 +11,8 @@ ExponentialLaw::ExponentialLaw() : { } -const char * ExponentialLaw::title() { - return "Loi exponentielle"; +I18n::Message ExponentialLaw::title() { + return I18n::Message::ExponentialLaw; } Law::Type ExponentialLaw::type() const { @@ -23,16 +23,14 @@ bool ExponentialLaw::isContinuous() const { return true; } -const char * ExponentialLaw::parameterNameAtIndex(int index) { +I18n::Message ExponentialLaw::parameterNameAtIndex(int index) { assert(index == 0); - constexpr static char name[] = {Ion::Charset::SmallLambda, 0}; - return name; + return I18n::Message::Lambda; } -const char * ExponentialLaw::parameterDefinitionAtIndex(int index) { +I18n::Message ExponentialLaw::parameterDefinitionAtIndex(int index) { assert(index == 0); - constexpr static char def[] = {Ion::Charset::SmallLambda, ' ', ':', ' ', 'p', 'a', 'r', 'a', 'm', 'e', 't', 'r', 'e', 0}; - return def; + return I18n::Message::LambdaExponentialDefinition; } float ExponentialLaw::xMin() { diff --git a/apps/probability/law/exponential_law.h b/apps/probability/law/exponential_law.h index 048c574f8..78ec639b3 100644 --- a/apps/probability/law/exponential_law.h +++ b/apps/probability/law/exponential_law.h @@ -9,15 +9,15 @@ class ExponentialLaw : public OneParameterLaw { public: ExponentialLaw(); ~ExponentialLaw() override {}; - const char * title() override; + I18n::Message title() override; Type type() const override; bool isContinuous() const override; float xMin() override; float yMin() override; float xMax() override; float yMax() override; - const char * parameterNameAtIndex(int index) override; - const char * parameterDefinitionAtIndex(int index) override; + I18n::Message parameterNameAtIndex(int index) override; + I18n::Message parameterDefinitionAtIndex(int index) override; float evaluateAtAbscissa(float x) const override; bool authorizedValueAtIndex(float x, int index) const override; float cumulativeDistributiveFunctionAtAbscissa(float x) const override; diff --git a/apps/probability/law/law.h b/apps/probability/law/law.h index d43e9f91f..b00be48b2 100644 --- a/apps/probability/law/law.h +++ b/apps/probability/law/law.h @@ -2,7 +2,9 @@ #define PROBABILITE_LAW_H #include +#include #include "../../shared/curve_view_range.h" +#include "../../i18n.h" namespace Probability { @@ -16,14 +18,14 @@ public: Poisson }; virtual ~Law() {}; - virtual const char * title() = 0; + virtual I18n::Message title() = 0; virtual Type type() const = 0; virtual bool isContinuous() const = 0; float xGridUnit() override; virtual int numberOfParameter() = 0; virtual float parameterValueAtIndex(int index) = 0; - virtual const char * parameterNameAtIndex(int index) = 0; - virtual const char * parameterDefinitionAtIndex(int index) = 0; + virtual I18n::Message parameterNameAtIndex(int index) = 0; + virtual I18n::Message parameterDefinitionAtIndex(int index) = 0; virtual void setParameterAtIndex(float f, int index) = 0; virtual float evaluateAtAbscissa(float x) const = 0; virtual bool authorizedValueAtIndex(float x, int index) const = 0; diff --git a/apps/probability/law/normal_law.cpp b/apps/probability/law/normal_law.cpp index 8b079c629..0931baa5d 100644 --- a/apps/probability/law/normal_law.cpp +++ b/apps/probability/law/normal_law.cpp @@ -11,8 +11,8 @@ NormalLaw::NormalLaw() : { } -const char * NormalLaw::title() { - return "Loi normale"; +I18n::Message NormalLaw::title() { + return I18n::Message::NormalLaw; } Law::Type NormalLaw::type() const { @@ -23,25 +23,21 @@ bool NormalLaw::isContinuous() const { return true; } -const char * NormalLaw::parameterNameAtIndex(int index) { +I18n::Message NormalLaw::parameterNameAtIndex(int index) { assert(index >= 0 && index < 2); if (index == 0) { - constexpr static char meanName[] = {Ion::Charset::SmallMu, 0}; - return meanName; + return I18n::Message::Mu; } else { - constexpr static char devName[] = {Ion::Charset::SmallSigma, 0}; - return devName; + return I18n::Message::Sigma; } } -const char * NormalLaw::parameterDefinitionAtIndex(int index) { +I18n::Message NormalLaw::parameterDefinitionAtIndex(int index) { assert(index >= 0 && index < 2); if (index == 0) { - constexpr static char meanDef[] = {Ion::Charset::SmallMu, ' ', ':', ' ', 'm', 'o', 'y', 'e', 'n', 'n', 'e', 0}; - return meanDef; + return I18n::Message::MeanDefinition; } else { - constexpr static char devDef[] = {Ion::Charset::SmallSigma, ' ', ':', ' ', 'e', 'c', 'a', 'r', 't', '-', 't', 'y', 'p', 'e', 0}; - return devDef; + return I18n::Message::DeviationDefinition; } } diff --git a/apps/probability/law/normal_law.h b/apps/probability/law/normal_law.h index 92a0da201..644d9853c 100644 --- a/apps/probability/law/normal_law.h +++ b/apps/probability/law/normal_law.h @@ -9,15 +9,15 @@ class NormalLaw : public TwoParameterLaw { public: NormalLaw(); ~NormalLaw() override {}; - const char * title() override; + I18n::Message title() override; Type type() const override; bool isContinuous() const override; float xMin() override; float yMin() override; float xMax() override; float yMax() override; - const char * parameterNameAtIndex(int index) override; - const char * parameterDefinitionAtIndex(int index) override; + I18n::Message parameterNameAtIndex(int index) override; + I18n::Message parameterDefinitionAtIndex(int index) override; float evaluateAtAbscissa(float x) const override; bool authorizedValueAtIndex(float x, int index) const override; float cumulativeDistributiveFunctionAtAbscissa(float x) const override; diff --git a/apps/probability/law/poisson_law.cpp b/apps/probability/law/poisson_law.cpp index 2da5e5073..f925ca991 100644 --- a/apps/probability/law/poisson_law.cpp +++ b/apps/probability/law/poisson_law.cpp @@ -10,8 +10,8 @@ PoissonLaw::PoissonLaw() : { } -const char * PoissonLaw::title() { - return "Loi Poisson"; +I18n::Message PoissonLaw::title() { + return I18n::Message::PoissonLaw; } Law::Type PoissonLaw::type() const { @@ -22,16 +22,14 @@ bool PoissonLaw::isContinuous() const { return false; } -const char * PoissonLaw::parameterNameAtIndex(int index) { +I18n::Message PoissonLaw::parameterNameAtIndex(int index) { assert(index == 0); - constexpr static char name[] = {Ion::Charset::SmallLambda, 0}; - return name; + return I18n::Message::Lambda; } -const char * PoissonLaw::parameterDefinitionAtIndex(int index) { +I18n::Message PoissonLaw::parameterDefinitionAtIndex(int index) { assert(index == 0); - constexpr static char meanDef[] = {Ion::Charset::SmallLambda, ' ', ':', ' ', 'p', 'a', 'r', 'a', 'm', 'e', 't', 'r', 'e', 0}; - return meanDef; + return I18n::Message::LambdaPoissonDefinition; } float PoissonLaw::xMin() { diff --git a/apps/probability/law/poisson_law.h b/apps/probability/law/poisson_law.h index ba2d4b8e0..6ca23a66d 100644 --- a/apps/probability/law/poisson_law.h +++ b/apps/probability/law/poisson_law.h @@ -9,15 +9,15 @@ class PoissonLaw : public OneParameterLaw { public: PoissonLaw(); ~PoissonLaw() override {}; - const char * title() override; + I18n::Message title() override; Type type() const override; bool isContinuous() const override; float xMin() override; float yMin() override; float xMax() override; float yMax() override; - const char * parameterNameAtIndex(int index) override; - const char * parameterDefinitionAtIndex(int index) override; + I18n::Message parameterNameAtIndex(int index) override; + I18n::Message parameterDefinitionAtIndex(int index) override; float evaluateAtAbscissa(float x) const override; bool authorizedValueAtIndex(float x, int index) const override; }; diff --git a/apps/probability/law/uniform_law.cpp b/apps/probability/law/uniform_law.cpp index e678e581e..22ab9a550 100644 --- a/apps/probability/law/uniform_law.cpp +++ b/apps/probability/law/uniform_law.cpp @@ -8,8 +8,8 @@ UniformLaw::UniformLaw() : { } -const char * UniformLaw::title() { - return "Loi uniforme"; +I18n::Message UniformLaw::title() { + return I18n::Message::UniformLaw; } Law::Type UniformLaw::type() const { @@ -20,21 +20,21 @@ bool UniformLaw::isContinuous() const { return true; } -const char * UniformLaw::parameterNameAtIndex(int index) { +I18n::Message UniformLaw::parameterNameAtIndex(int index) { assert(index >= 0 && index < 2); if (index == 0) { - return "a"; + return I18n::Message::A; } else { - return "b"; + return I18n::Message::B; } } -const char * UniformLaw::parameterDefinitionAtIndex(int index) { +I18n::Message UniformLaw::parameterDefinitionAtIndex(int index) { assert(index >= 0 && index < 2); if (index == 0) { - return "[a, b] intervalle"; + return I18n::Message::IntervalDefinition; } else { - return nullptr; + return I18n::Message::Default; } } diff --git a/apps/probability/law/uniform_law.h b/apps/probability/law/uniform_law.h index e07148282..572ff95b1 100644 --- a/apps/probability/law/uniform_law.h +++ b/apps/probability/law/uniform_law.h @@ -9,15 +9,15 @@ class UniformLaw : public TwoParameterLaw { public: UniformLaw(); ~UniformLaw() override {}; - const char * title() override; + I18n::Message title() override; Type type() const override; bool isContinuous() const override; float xMin() override; float yMin() override; float xMax() override; float yMax() override; - const char * parameterNameAtIndex(int index) override; - const char * parameterDefinitionAtIndex(int index) override; + I18n::Message parameterNameAtIndex(int index) override; + I18n::Message parameterDefinitionAtIndex(int index) override; float evaluateAtAbscissa(float x) const override; bool authorizedValueAtIndex(float x, int index) const override; float cumulativeDistributiveFunctionAtAbscissa(float x) const override; diff --git a/apps/probability/law_controller.cpp b/apps/probability/law_controller.cpp index 17aaa30b3..5435bfca3 100644 --- a/apps/probability/law_controller.cpp +++ b/apps/probability/law_controller.cpp @@ -20,7 +20,7 @@ namespace Probability { LawController::ContentView::ContentView(SelectableTableView * selectableTableView) : - m_titleView(PointerTextView(KDText::FontSize::Small, "Choisir le type de loi", 0.5f, 0.5f, Palette::GreyDark, Palette::WallScreen)), + m_titleView(PointerTextView(KDText::FontSize::Small, I18n::Message::ChooseLaw, 0.5f, 0.5f, Palette::GreyDark, Palette::WallScreen)), m_selectableTableView(selectableTableView) { } @@ -43,12 +43,12 @@ void LawController::ContentView::layoutSubviews() { m_selectableTableView->setFrame(KDRect(0, titleHeight, bounds().width(), bounds().height()-titleHeight)); } -static const char * sMessages[] = { - "Binomiale", - "Uniforme", - "Exponentielle", - "Normale", - "Poisson" +static I18n::Message sMessages[] = { + I18n::Message::Binomial, + I18n::Message::Uniforme, + I18n::Message::Exponential, + I18n::Message::Normal, + I18n::Message::Poisson }; LawController::LawController(Responder * parentResponder) : diff --git a/apps/probability/law_controller.h b/apps/probability/law_controller.h index 5d070d836..c38b8e717 100644 --- a/apps/probability/law_controller.h +++ b/apps/probability/law_controller.h @@ -37,7 +37,7 @@ private: Cell m_cells[k_totalNumberOfModels]; SelectableTableView m_selectableTableView; ContentView m_contentView; - const char ** m_messages; + I18n::Message * m_messages; Law * m_law; ParametersController m_parametersController; diff --git a/apps/probability/parameters_controller.cpp b/apps/probability/parameters_controller.cpp index 90d0d30c1..bc52c4702 100644 --- a/apps/probability/parameters_controller.cpp +++ b/apps/probability/parameters_controller.cpp @@ -8,9 +8,9 @@ namespace Probability { ParametersController::ContentView::ContentView(Responder * parentResponder, SelectableTableView * selectableTableView) : m_numberOfParameters(1), - m_titleView(PointerTextView(KDText::FontSize::Small, "Choisir les parametres", 0.5f, 0.5f, Palette::GreyDark, Palette::WallScreen)), - m_firstParameterDefinition(PointerTextView(KDText::FontSize::Small, nullptr, 0.5f, 0.5f, KDColorBlack, Palette::WallScreen)), - m_secondParameterDefinition(PointerTextView(KDText::FontSize::Small, nullptr, 0.5f, 0.5f, KDColorBlack, Palette::WallScreen)), + m_titleView(PointerTextView(KDText::FontSize::Small, I18n::Message::ChooseParameters, 0.5f, 0.5f, Palette::GreyDark, Palette::WallScreen)), + m_firstParameterDefinition(PointerTextView(KDText::FontSize::Small, (I18n::Message)0, 0.5f, 0.5f, KDColorBlack, Palette::WallScreen)), + m_secondParameterDefinition(PointerTextView(KDText::FontSize::Small, (I18n::Message)0, 0.5f, 0.5f, KDColorBlack, Palette::WallScreen)), m_selectableTableView(selectableTableView) { } @@ -68,7 +68,7 @@ void ParametersController::ContentView::layoutSubviews() { /* Parameters Controller */ ParametersController::ParametersController(Responder * parentResponder) : - FloatParameterController(parentResponder, "Suivant"), + FloatParameterController(parentResponder, I18n::Message::Next), m_menuListCell{PointerTableCellWithEditableText(&m_selectableTableView, this, m_draftTextBuffer), PointerTableCellWithEditableText(&m_selectableTableView, this, m_draftTextBuffer)}, m_contentView(ContentView(this, &m_selectableTableView)), @@ -81,9 +81,9 @@ View * ParametersController::view() { return &m_contentView; } -const char * ParametersController::title() const { +const char * ParametersController::title() { if (m_law != nullptr) { - return m_law->title(); + return I18n::translate(m_law->title()); } return ""; } @@ -99,7 +99,7 @@ void ParametersController::setLaw(Law * law) { void ParametersController::viewWillAppear() { for (int i = 0; i < m_law->numberOfParameter(); i++) { m_previousParameters[i] = parameterAtIndex(i); - m_contentView.parameterDefinitionAtIndex(i)->setText(m_law->parameterDefinitionAtIndex(i)); + m_contentView.parameterDefinitionAtIndex(i)->setMessage(m_law->parameterDefinitionAtIndex(i)); } m_contentView.layoutSubviews(); FloatParameterController::viewWillAppear(); @@ -114,7 +114,7 @@ void ParametersController::willDisplayCellForIndex(HighlightCell * cell, int ind return; } PointerTableCellWithEditableText * myCell = (PointerTableCellWithEditableText *) cell; - myCell->setText(m_law->parameterNameAtIndex(index)); + myCell->setMessage(m_law->parameterNameAtIndex(index)); FloatParameterController::willDisplayCellForIndex(cell, index); } @@ -140,7 +140,7 @@ float ParametersController::parameterAtIndex(int index) { void ParametersController::setParameterAtIndex(int parameterIndex, float f) { if (!m_law->authorizedValueAtIndex(f, parameterIndex)) { - app()->displayWarning("Cette valeur est interdite !"); + app()->displayWarning(I18n::Message::ForbiddenValue); return; } m_law->setParameterAtIndex(f, parameterIndex); diff --git a/apps/probability/parameters_controller.h b/apps/probability/parameters_controller.h index f2a337787..2ef55c4f0 100644 --- a/apps/probability/parameters_controller.h +++ b/apps/probability/parameters_controller.h @@ -12,7 +12,7 @@ class ParametersController : public Shared::FloatParameterController { public: ParametersController(Responder * parentResponder); View * view() override; - const char * title() const override; + const char * title() override; void setLaw(Law * law); void viewWillAppear() override; int numberOfRows() override; diff --git a/apps/regression/app.cpp b/apps/regression/app.cpp index aa8fd0181..b3eebcafe 100644 --- a/apps/regression/app.cpp +++ b/apps/regression/app.cpp @@ -1,12 +1,13 @@ #include "app.h" #include "regression_icon.h" +#include "../i18n.h" using namespace Shared; namespace Regression { App::App(Container * container) : - TextFieldDelegateApp(container, &m_tabViewController, "Regression", "REGRESSION", ImageStore::RegressionIcon), + TextFieldDelegateApp(container, &m_tabViewController, I18n::Message::RegressionApp, I18n::Message::RegressionAppCapital, ImageStore::RegressionIcon), m_store(), m_calculationController(CalculationController(&m_calculationAlternateEmptyViewController, &m_calculationHeader, &m_store)), m_calculationAlternateEmptyViewController(AlternateEmptyViewController(&m_calculationHeader, &m_calculationController, &m_calculationController)), diff --git a/apps/regression/banner_view.cpp b/apps/regression/banner_view.cpp index 8b13324cd..93bea3f97 100644 --- a/apps/regression/banner_view.cpp +++ b/apps/regression/banner_view.cpp @@ -3,7 +3,7 @@ namespace Regression { BannerView::BannerView() : - m_regressionTypeView(KDText::FontSize::Small, nullptr, 0.5f, 0.5f, KDColorBlack, Palette::GreyMiddle), + m_regressionTypeView(KDText::FontSize::Small, (I18n::Message)0, 0.5f, 0.5f, KDColorBlack, Palette::GreyMiddle), m_slopeView(KDText::FontSize::Small, 0.5f, 0.5f, KDColorBlack, Palette::GreyMiddle), m_yInterceptView(KDText::FontSize::Small, 0.5f, 0.5f, KDColorBlack, Palette::GreyMiddle), m_xView(KDText::FontSize::Small, 0.5f, 0.5f, KDColorBlack, Palette::GreyMiddle), @@ -20,4 +20,11 @@ TextView * BannerView::textViewAtIndex(int i) const { return (TextView *)textViews[i]; } +PointerTextView * BannerView::pointerTextViewAtIndex(int i) const { + if (i == 0) { + return (PointerTextView *)&m_regressionTypeView; + } + return nullptr; +} + } diff --git a/apps/regression/banner_view.h b/apps/regression/banner_view.h index 4a03c82cd..dcf58208c 100644 --- a/apps/regression/banner_view.h +++ b/apps/regression/banner_view.h @@ -12,6 +12,7 @@ public: private: int numberOfSubviews() const override; TextView * textViewAtIndex(int i) const override; + PointerTextView * pointerTextViewAtIndex(int i) const override; PointerTextView m_regressionTypeView; BufferTextView m_slopeView; BufferTextView m_yInterceptView; diff --git a/apps/regression/calculation_controller.cpp b/apps/regression/calculation_controller.cpp index e18578df8..3ff469f8e 100644 --- a/apps/regression/calculation_controller.cpp +++ b/apps/regression/calculation_controller.cpp @@ -36,8 +36,8 @@ CalculationController::~CalculationController() { } } -const char * CalculationController::title() const { - return "Statistiques"; +const char * CalculationController::title() { + return I18n::translate(I18n::Message::StatTab); } bool CalculationController::handleEvent(Ion::Events::Event event) { @@ -99,8 +99,8 @@ bool CalculationController::isEmpty() const { return false; } -const char * CalculationController::emptyMessage() { - return "Aucune grandeur a calculer"; +I18n::Message CalculationController::emptyMessage() { + return I18n::Message::NoValueToCompute; } Responder * CalculationController::defaultController() { @@ -133,14 +133,12 @@ void CalculationController::willDisplayCellAtLocation(HighlightCell * cell, int } EvenOddPointerTextCell * myCell = (EvenOddPointerTextCell *)cell; if (j == 0) { - myCell->setText(""); + myCell->setMessage(I18n::Message::Default); return; } myCell->setAlignment(1.0f, 0.5f); - const char sxy[4] = {Ion::Charset::CapitalSigma, 'x', 'y', 0}; - const char * titles[k_totalNumberOfRows-1] = {"Moyenne", "Somme", "Somme des carres", "Ecart-type", "Variance", - "Nombre de points", "Covariance", sxy, "r", "r2"}; - myCell->setText(titles[j-1]); + I18n::Message titles[k_totalNumberOfRows-1] = {I18n::Message::Mean, I18n::Message::Sum, I18n::Message::SquareSum, I18n::Message::StandardDeviation, I18n::Message::Deviation, I18n::Message::NumberOfDots, I18n::Message::Covariance, I18n::Message::Sxy, I18n::Message::R, I18n::Message::Default}; + myCell->setMessage(titles[j-1]); return; } if (i == 1 && j > 0 && j < 6) { diff --git a/apps/regression/calculation_controller.h b/apps/regression/calculation_controller.h index d98f1fa88..ed125ab25 100644 --- a/apps/regression/calculation_controller.h +++ b/apps/regression/calculation_controller.h @@ -13,13 +13,13 @@ class CalculationController : public Shared::TabTableController, public ButtonRo public: CalculationController(Responder * parentResponder, ButtonRowController * header, Store * store); ~CalculationController(); - const char * title() const override; + const char * title() override; bool handleEvent(Ion::Events::Event event) override; void didBecomeFirstResponder() override; void tableViewDidChangeSelection(SelectableTableView * t, int previousSelectedCellX, int previousSelectedCellY) override; bool isEmpty() const override; - const char * emptyMessage() override; + I18n::Message emptyMessage() override; Responder * defaultController() override; int numberOfRows() override; diff --git a/apps/regression/go_to_parameter_controller.cpp b/apps/regression/go_to_parameter_controller.cpp index 8e9083175..cfab6107b 100644 --- a/apps/regression/go_to_parameter_controller.cpp +++ b/apps/regression/go_to_parameter_controller.cpp @@ -8,7 +8,7 @@ using namespace Poincare; namespace Regression { GoToParameterController::GoToParameterController(Responder * parentResponder, Store * store, CurveViewCursor * cursor) : - FloatParameterController(parentResponder, "Valider"), + FloatParameterController(parentResponder), m_abscisseCell(PointerTableCellWithEditableText(&m_selectableTableView, this, m_draftTextBuffer)), m_store(store), m_cursor(cursor), @@ -20,7 +20,7 @@ void GoToParameterController::setXPrediction(bool xPrediction) { m_xPrediction = xPrediction; } -const char * GoToParameterController::title() const { +const char * GoToParameterController::title() { if (m_xPrediction) { return "Prediction sachant x"; } @@ -77,9 +77,9 @@ void GoToParameterController::willDisplayCellForIndex(HighlightCell * cell, int } PointerTableCellWithEditableText * myCell = (PointerTableCellWithEditableText *) cell; if (m_xPrediction) { - myCell->setText("x"); + myCell->setMessage(I18n::Message::X); } else { - myCell->setText("y"); + myCell->setMessage(I18n::Message::Y); } FloatParameterController::willDisplayCellForIndex(cell, index); } @@ -93,7 +93,7 @@ bool GoToParameterController::textFieldDidFinishEditing(TextField * textField, c parameter = m_store->xValueForYValue(floatBody); } if (isnan(parameter)) { - app()->displayWarning("Valeur non atteinte par la regression"); + app()->displayWarning(I18n::Message::ValueNotReachedByRegression); return false; } return FloatParameterController::textFieldDidFinishEditing(textField, text); diff --git a/apps/regression/go_to_parameter_controller.h b/apps/regression/go_to_parameter_controller.h index d02672692..6bb76c93a 100644 --- a/apps/regression/go_to_parameter_controller.h +++ b/apps/regression/go_to_parameter_controller.h @@ -12,7 +12,7 @@ class GoToParameterController : public Shared::FloatParameterController { public: GoToParameterController(Responder * parentResponder, Store * store, Shared::CurveViewCursor * cursor); void setXPrediction(bool xPrediction); - const char * title() const override; + const char * title() override; int numberOfRows() override; void willDisplayCellForIndex(HighlightCell * cell, int index) override; bool textFieldDidFinishEditing(TextField * textField, const char * text) override; diff --git a/apps/regression/graph_controller.cpp b/apps/regression/graph_controller.cpp index ea5a44bd1..9b7386905 100644 --- a/apps/regression/graph_controller.cpp +++ b/apps/regression/graph_controller.cpp @@ -29,11 +29,11 @@ bool GraphController::isEmpty() const { return false; } -const char * GraphController::emptyMessage() { +I18n::Message GraphController::emptyMessage() { if (m_store->numberOfPairs() == 0) { - return "Aucune donnee a tracer"; + return I18n::Message::NoDataToPlot; } - return "Pas assez de donnees pour un regression"; + return I18n::Message::NoEnoughDataForRegression; } BannerView * GraphController::bannerView() { @@ -54,7 +54,7 @@ bool GraphController::handleEnter() { } void GraphController::reloadBannerView() { - m_bannerView.setLegendAtIndex((char *)" y=ax+b ", 0); + m_bannerView.setMessageAtIndex(I18n::Message::RegressionFormula, 0); char buffer[k_maxNumberOfCharacters + Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)]; int numberOfChar = 0; const char * legend = "a="; diff --git a/apps/regression/graph_controller.h b/apps/regression/graph_controller.h index 8d612e0d7..be6c0c3f4 100644 --- a/apps/regression/graph_controller.h +++ b/apps/regression/graph_controller.h @@ -17,7 +17,7 @@ public: GraphController(Responder * parentResponder, ButtonRowController * header, Store * store); ViewController * initialisationParameterController() override; bool isEmpty() const override; - const char * emptyMessage() override; + I18n::Message emptyMessage() override; private: constexpr static float k_cursorTopMarginRatio = 0.07f; // (cursorHeight/2)/graphViewHeight constexpr static float k_cursorRightMarginRatio = 0.04f; // (cursorWidth/2)/graphViewWidth @@ -49,4 +49,4 @@ private: } -#endif \ No newline at end of file +#endif diff --git a/apps/regression/initialisation_parameter_controller.cpp b/apps/regression/initialisation_parameter_controller.cpp index e6722b852..bfcda593f 100644 --- a/apps/regression/initialisation_parameter_controller.cpp +++ b/apps/regression/initialisation_parameter_controller.cpp @@ -14,8 +14,8 @@ InitialisationParameterController::InitialisationParameterController(Responder * { } -const char * InitialisationParameterController::title() const { - return "Zoom predefini"; +const char * InitialisationParameterController::title() { + return I18n::translate(I18n::Message::PredefinedZoom); } View * InitialisationParameterController::view() { @@ -60,8 +60,8 @@ KDCoordinate InitialisationParameterController::cellHeight() { void InitialisationParameterController::willDisplayCellForIndex(HighlightCell * cell, int index) { PointerTableCell * myCell = (PointerTableCell *)cell; - const char * titles[3] = {"Abscisses entieres", "Orthonorme", "Reglage de base"}; - myCell->setText(titles[index]); + I18n::Message titles[3] = {I18n::Message::RoundAbscissa, I18n::Message::Orthonormal, I18n::Message::DefaultSetting}; + myCell->setMessage(titles[index]); } } diff --git a/apps/regression/initialisation_parameter_controller.h b/apps/regression/initialisation_parameter_controller.h index 72f49b769..e36940901 100644 --- a/apps/regression/initialisation_parameter_controller.h +++ b/apps/regression/initialisation_parameter_controller.h @@ -3,6 +3,7 @@ #include #include "store.h" +#include "../i18n.h" namespace Regression { @@ -10,7 +11,7 @@ class InitialisationParameterController : public ViewController, public SimpleLi public: InitialisationParameterController(Responder * parentResponder, Store * store); View * view() override; - const char * title() const override; + const char * title() override; bool handleEvent(Ion::Events::Event event) override; void didBecomeFirstResponder() override; int numberOfRows() override; diff --git a/apps/regression/prediction_parameter_controller.cpp b/apps/regression/prediction_parameter_controller.cpp index 19ccaa597..bfce066b3 100644 --- a/apps/regression/prediction_parameter_controller.cpp +++ b/apps/regression/prediction_parameter_controller.cpp @@ -13,8 +13,8 @@ PredictionParameterController::PredictionParameterController(Responder * parentR { } -const char * PredictionParameterController::title() const { - return "Droite de regression"; +const char * PredictionParameterController::title() { + return I18n::translate(I18n::Message::RegressionSlope); } View * PredictionParameterController::view() { @@ -56,8 +56,8 @@ KDCoordinate PredictionParameterController::cellHeight() { void PredictionParameterController::willDisplayCellForIndex(HighlightCell * cell, int index) { PointerTableCellWithChevron * myCell = (PointerTableCellWithChevron *)cell; - const char * titles[3] = {"Prediction sachant x", "Prediction sachant y"}; - myCell->setText(titles[index]); + I18n::Message titles[2] = {I18n::Message::XPrediction, I18n::Message::YPrediction}; + myCell->setMessage(titles[index]); } } diff --git a/apps/regression/prediction_parameter_controller.h b/apps/regression/prediction_parameter_controller.h index 8699de7a0..229e0dd59 100644 --- a/apps/regression/prediction_parameter_controller.h +++ b/apps/regression/prediction_parameter_controller.h @@ -12,7 +12,7 @@ class PredictionParameterController : public ViewController, public SimpleListVi public: PredictionParameterController(Responder * parentResponder, Store * store, Shared::CurveViewCursor * cursor); View * view() override; - const char * title() const override; + const char * title() override; bool handleEvent(Ion::Events::Event event) override; void didBecomeFirstResponder() override; int numberOfRows() override; diff --git a/apps/sequence/app.cpp b/apps/sequence/app.cpp index 9287fe8ee..4cecada00 100644 --- a/apps/sequence/app.cpp +++ b/apps/sequence/app.cpp @@ -6,7 +6,7 @@ using namespace Poincare; namespace Sequence { App::App(Container * container, Context * context) : - TextFieldDelegateApp(container, &m_inputViewController, "Suites", "SUITES", ImageStore::SequenceIcon), + TextFieldDelegateApp(container, &m_inputViewController, I18n::Message::SequenceApp, I18n::Message::SequenceAppCapital, ImageStore::SequenceIcon), m_sequenceStore(SequenceStore()), m_nContext(LocalContext(context)), m_listController(&m_listFooter, &m_sequenceStore, &m_listHeader, &m_listFooter), diff --git a/apps/sequence/graph/curve_parameter_controller.cpp b/apps/sequence/graph/curve_parameter_controller.cpp index 1a15be626..648d5c7d3 100644 --- a/apps/sequence/graph/curve_parameter_controller.cpp +++ b/apps/sequence/graph/curve_parameter_controller.cpp @@ -7,14 +7,14 @@ using namespace Shared; namespace Sequence { CurveParameterController::CurveParameterController(GraphController * graphController, InteractiveCurveViewRange * graphRange, CurveViewCursor * cursor) : - FunctionCurveParameterController(graphRange, cursor, "n"), - m_sumCell(PointerTableCell((char*)"Somme des termes")), + FunctionCurveParameterController(graphRange, cursor, I18n::Message::N), + m_sumCell(PointerTableCell(I18n::Message::TermSum)), m_graphController(graphController) { } -const char * CurveParameterController::title() const { - return "Options de la suite"; +const char * CurveParameterController::title() { + return I18n::translate(I18n::Message::SequenceOptions); } bool CurveParameterController::handleEvent(Ion::Events::Event event) { diff --git a/apps/sequence/graph/curve_parameter_controller.h b/apps/sequence/graph/curve_parameter_controller.h index b790594a2..03203b367 100644 --- a/apps/sequence/graph/curve_parameter_controller.h +++ b/apps/sequence/graph/curve_parameter_controller.h @@ -11,7 +11,7 @@ class GraphController; class CurveParameterController : public Shared::FunctionCurveParameterController { public: CurveParameterController(GraphController * graphController, Shared::InteractiveCurveViewRange * graphRange, Shared::CurveViewCursor * cursor); - const char * title() const override; + const char * title() override; bool handleEvent(Ion::Events::Event event) override; int numberOfRows() override; HighlightCell * reusableCell(int index) override; diff --git a/apps/sequence/graph/graph_controller.cpp b/apps/sequence/graph/graph_controller.cpp index 23d5e654b..a7ef02154 100644 --- a/apps/sequence/graph/graph_controller.cpp +++ b/apps/sequence/graph/graph_controller.cpp @@ -23,11 +23,11 @@ void GraphController::viewWillAppear() { FunctionGraphController::viewWillAppear(); } -const char * GraphController::emptyMessage() { +I18n::Message GraphController::emptyMessage() { if (m_sequenceStore->numberOfDefinedFunctions() == 0) { - return "Aucune suite"; + return I18n::Message::NoSequence; } - return "Aucune suite activee"; + return I18n::Message::NoActivatedSequence; } TermSumController * GraphController::termSumController() { diff --git a/apps/sequence/graph/graph_controller.h b/apps/sequence/graph/graph_controller.h index 8e7143a8d..dc30ff389 100644 --- a/apps/sequence/graph/graph_controller.h +++ b/apps/sequence/graph/graph_controller.h @@ -15,7 +15,7 @@ class GraphController : public Shared::FunctionGraphController { public: GraphController(Responder * parentResponder, SequenceStore * sequenceStore, ButtonRowController * header); void viewWillAppear() override; - const char * emptyMessage() override; + I18n::Message emptyMessage() override; TermSumController * termSumController(); private: BannerView * bannerView() override; diff --git a/apps/sequence/graph/term_sum_controller.cpp b/apps/sequence/graph/term_sum_controller.cpp index 2c03ee42a..f43d174eb 100644 --- a/apps/sequence/graph/term_sum_controller.cpp +++ b/apps/sequence/graph/term_sum_controller.cpp @@ -27,8 +27,8 @@ TermSumController::TermSumController(Responder * parentResponder, GraphView * gr { } -const char * TermSumController::title() const { - return "Sommes des termes"; +const char * TermSumController::title() { + return I18n::translate(I18n::Message::TermSum); } View * TermSumController::view() { @@ -49,7 +49,7 @@ void TermSumController::viewWillAppear() { m_startSum = -1; m_endSum = -1; m_step = 0; - m_contentView.legendView()->setLegendText("SELECTIONNER LE PREMIER TERME"); + m_contentView.legendView()->setLegendMessage(I18n::Message::SelectFirstTerm); m_contentView.legendView()->setSumSubscript(m_cursor->x()); } @@ -94,20 +94,17 @@ bool TermSumController::handleEvent(Ion::Events::Event event) { m_step++; m_startSum = m_cursor->x(); m_contentView.legendView()->setSumSuperscript(m_startSum, m_cursor->x()); - m_contentView.legendView()->setLegendText("SELECTIONNER LE DERNIER TERME"); + m_contentView.legendView()->setLegendMessage(I18n::Message::SelectLastTerm); return true; } m_step++; m_endSum = m_cursor->x(); - m_contentView.legendView()->setSequenceName(m_sequence->name()); - char buffer[2+Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)]; - strlcpy(buffer, "= ", 3); TextFieldDelegateApp * myApp = (TextFieldDelegateApp *)app(); float sum = m_sequence->sumOfTermsBetweenAbscissa(m_startSum, m_endSum, myApp->localContext()); - Complex::convertFloatToText(sum, buffer+2, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); + m_contentView.legendView()->setSumResult(m_sequence->name(), sum); + m_contentView.legendView()->setLegendMessage(I18n::Message::Default); m_contentView.graphView()->setHighlightColor(true); m_contentView.graphView()->selectMainView(false); - m_contentView.legendView()->setLegendText(buffer); return true; } return false; @@ -177,7 +174,7 @@ View * TermSumController::ContentView::subviewAtIndex(int index) { TermSumController::ContentView::LegendView::LegendView() : m_sum(ExpressionView(0.0f, 0.5f, KDColorBlack, Palette::GreyBright)), m_sumLayout(nullptr), - m_legend(BufferTextView(KDText::FontSize::Small, 0.0f, 0.5f, KDColorBlack, Palette::GreyBright)) + m_legend(PointerTextView(KDText::FontSize::Small, I18n::Message::Default, 0.0f, 0.5f, KDColorBlack, Palette::GreyBright)) { } @@ -192,8 +189,8 @@ void TermSumController::ContentView::LegendView::drawRect(KDContext * ctx, KDRec ctx->fillRect(KDRect(0, bounds().height() - k_legendHeight, bounds().width(), k_legendHeight), Palette::GreyBright); } -void TermSumController::ContentView::LegendView::setLegendText(const char * text) { - m_legend.setText(text); +void TermSumController::ContentView::LegendView::setLegendMessage(I18n::Message message) { + m_legend.setMessage(message); layoutSubviews(); } @@ -226,13 +223,17 @@ void TermSumController::ContentView::LegendView::setSumSuperscript(float start, layoutSubviews(); } -void TermSumController::ContentView::LegendView::setSequenceName(const char * sequenceName) { - ExpressionLayout * childrenLayouts[2]; +void TermSumController::ContentView::LegendView::setSumResult(const char * sequenceName, float result) { + ExpressionLayout * childrenLayouts[3]; + char buffer[2+Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)]; + strlcpy(buffer, "= ", 3); + Complex::convertFloatToText(result, buffer+2, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); + childrenLayouts[2] = new StringLayout(buffer, strlen(buffer), KDText::FontSize::Small); childrenLayouts[1] = new BaselineRelativeLayout(new StringLayout(sequenceName, 1, KDText::FontSize::Small), new StringLayout("n", 1, KDText::FontSize::Small), BaselineRelativeLayout::Type::Subscript); childrenLayouts[0] = m_sumLayout; - m_sumLayout = new HorizontalLayout(childrenLayouts, 2); + m_sumLayout = new HorizontalLayout(childrenLayouts, 3); m_sum.setExpression(m_sumLayout); - m_sum.setAlignment(1.0f, 0.5f); + m_sum.setAlignment(0.5f, 0.5f); layoutSubviews(); } @@ -252,13 +253,13 @@ void TermSumController::ContentView::LegendView::layoutSubviews() { KDCoordinate width = bounds().width(); KDCoordinate heigth = bounds().height(); KDSize legendSize = m_legend.minimalSizeForOptimalDisplay(); - if (legendSize.width() > width/2) { + if (legendSize.width() > 0) { m_sum.setFrame(KDRect(0, 0, width-legendSize.width(), heigth)); m_legend.setFrame(KDRect(width-legendSize.width(), 0, legendSize.width(), heigth)); return; } - m_sum.setFrame(KDRect(0, 0, width/2, heigth)); - m_legend.setFrame(KDRect(width/2, 0, width/2, heigth)); + m_sum.setFrame(bounds()); + m_legend.setFrame(KDRectZero); } } diff --git a/apps/sequence/graph/term_sum_controller.h b/apps/sequence/graph/term_sum_controller.h index 31721c793..da2cd58ce 100644 --- a/apps/sequence/graph/term_sum_controller.h +++ b/apps/sequence/graph/term_sum_controller.h @@ -12,7 +12,7 @@ namespace Sequence { class TermSumController : public ViewController { public: TermSumController(Responder * parentResponder, GraphView * graphView, CurveViewRange * graphRange, Shared::CurveViewCursor * cursor); - const char * title() const override; + const char * title() override; View * view() override; void viewWillAppear() override; bool handleEvent(Ion::Events::Event event) override; @@ -30,17 +30,17 @@ private: LegendView(); ~LegendView(); void drawRect(KDContext * ctx, KDRect rect) const override; - void setLegendText(const char * text); + void setLegendMessage(I18n::Message message); void setSumSubscript(float start); void setSumSuperscript(float start, float end); - void setSequenceName(const char * sequenceName); + void setSumResult(const char * sequenceName, float result); private: void layoutSubviews() override; int numberOfSubviews() const override; View * subviewAtIndex(int index) override; ExpressionView m_sum; Poincare::ExpressionLayout * m_sumLayout; - BufferTextView m_legend; + PointerTextView m_legend; }; ContentView(GraphView * graphView); void layoutSubviews() override; diff --git a/apps/sequence/list/list_controller.cpp b/apps/sequence/list/list_controller.cpp index 9b047de75..b1360c432 100644 --- a/apps/sequence/list/list_controller.cpp +++ b/apps/sequence/list/list_controller.cpp @@ -8,7 +8,7 @@ using namespace Poincare; namespace Sequence { ListController::ListController(Responder * parentResponder, SequenceStore * sequenceStore, ButtonRowController * header, ButtonRowController * footer) : - Shared::ListController(parentResponder, sequenceStore, header, footer, "Ajouter une suite"), + Shared::ListController(parentResponder, sequenceStore, header, footer, I18n::Message::AddSequence), m_sequenceStore(sequenceStore), m_sequenceTitleCells{SequenceTitleCell(FunctionTitleCell::Orientation::VerticalIndicator), SequenceTitleCell(FunctionTitleCell::Orientation::VerticalIndicator), SequenceTitleCell(FunctionTitleCell::Orientation::VerticalIndicator), SequenceTitleCell(FunctionTitleCell::Orientation::VerticalIndicator), SequenceTitleCell(FunctionTitleCell::Orientation::VerticalIndicator), SequenceTitleCell(FunctionTitleCell::Orientation::VerticalIndicator), SequenceTitleCell(FunctionTitleCell::Orientation::VerticalIndicator), @@ -20,8 +20,8 @@ ListController::ListController(Responder * parentResponder, SequenceStore * sequ { } -const char * ListController::title() const { - return "Suites"; +const char * ListController::title() { + return I18n::translate(I18n::Message::SequenceTab); } Toolbox * ListController::toolboxForTextField(TextField * textField) { diff --git a/apps/sequence/list/list_controller.h b/apps/sequence/list/list_controller.h index bf0dd26af..873c93269 100644 --- a/apps/sequence/list/list_controller.h +++ b/apps/sequence/list/list_controller.h @@ -17,7 +17,7 @@ namespace Sequence { class ListController : public Shared::ListController, public Shared::TextFieldDelegate { public: ListController(Responder * parentResponder, SequenceStore * sequenceStore, ButtonRowController * header, ButtonRowController * footer); - const char * title() const override; + const char * title() override; int numberOfRows() override; virtual KDCoordinate rowHeight(int j) override; void willDisplayCellAtLocation(HighlightCell * cell, int i, int j) override; diff --git a/apps/sequence/list/list_parameter_controller.cpp b/apps/sequence/list/list_parameter_controller.cpp index 5b65d39b6..b986e8916 100644 --- a/apps/sequence/list/list_parameter_controller.cpp +++ b/apps/sequence/list/list_parameter_controller.cpp @@ -7,15 +7,15 @@ using namespace Shared; namespace Sequence { ListParameterController::ListParameterController(ListController * listController, SequenceStore * sequenceStore) : - Shared::ListParameterController(listController, sequenceStore), - m_typeCell(PointerTableCellWithChevronAndExpression((char *)"Type de suite")), + Shared::ListParameterController(listController, sequenceStore, I18n::Message::SequenceColor, I18n::Message::DeleteSequence), + m_typeCell(PointerTableCellWithChevronAndExpression(I18n::Message::SequenceType)), m_typeParameterController(TypeParameterController(this, sequenceStore, listController, TableCell::Layout::Horizontal, Metric::CommonTopMargin, Metric::CommonRightMargin, Metric::CommonBottomMargin, Metric::CommonLeftMargin)) { } -const char * ListParameterController::title() const { - return "Options de la suite"; +const char * ListParameterController::title() { + return I18n::translate(I18n::Message::SequenceOptions); } void ListParameterController::setFunction(Shared::Function * function) { diff --git a/apps/sequence/list/list_parameter_controller.h b/apps/sequence/list/list_parameter_controller.h index 1c1276137..97b38f0d2 100644 --- a/apps/sequence/list/list_parameter_controller.h +++ b/apps/sequence/list/list_parameter_controller.h @@ -13,7 +13,7 @@ class ListController; class ListParameterController : public Shared::ListParameterController { public: ListParameterController(ListController * list, SequenceStore * sequenceStore); - const char * title() const override; + const char * title() override; bool handleEvent(Ion::Events::Event event) override; void setFunction(Shared::Function * function) override; int numberOfRows() override; diff --git a/apps/sequence/list/type_parameter_controller.cpp b/apps/sequence/list/type_parameter_controller.cpp index c6cfcadbc..bdf439564 100644 --- a/apps/sequence/list/type_parameter_controller.cpp +++ b/apps/sequence/list/type_parameter_controller.cpp @@ -11,9 +11,9 @@ namespace Sequence { TypeParameterController::TypeParameterController(Responder * parentResponder, SequenceStore * sequenceStore, ListController * list, TableCell::Layout cellLayout, KDCoordinate topMargin, KDCoordinate rightMargin, KDCoordinate bottomMargin, KDCoordinate leftMargin) : ViewController(parentResponder), - m_expliciteCell(ExpressionTableCellWithPointer((char*)"Explicite", cellLayout)), - m_singleRecurrenceCell(ExpressionTableCellWithPointer((char*)"Recurrence d'ordre 1", cellLayout)), - m_doubleRecurenceCell(ExpressionTableCellWithPointer((char*)"Recurrence d'ordre 2", cellLayout)), + m_expliciteCell(ExpressionTableCellWithPointer(I18n::Message::Explicite, cellLayout)), + m_singleRecurrenceCell(ExpressionTableCellWithPointer(I18n::Message::SingleRecurrence, cellLayout)), + m_doubleRecurenceCell(ExpressionTableCellWithPointer(I18n::Message::DoubleRecurrence, cellLayout)), m_selectableTableView(SelectableTableView(this, this, 1, topMargin, rightMargin, bottomMargin, leftMargin, nullptr, false)), m_sequenceStore(sequenceStore), m_sequence(nullptr), @@ -30,11 +30,11 @@ TypeParameterController::~TypeParameterController() { } } -const char * TypeParameterController::title() const { +const char * TypeParameterController::title() { if (m_sequence) { - return "Type de suite"; + return I18n::translate(I18n::Message::SequenceType); } - return "Choisir le type de suite"; + return I18n::translate(I18n::Message::ChooseSequenceType); } View * TypeParameterController::view() { diff --git a/apps/sequence/list/type_parameter_controller.h b/apps/sequence/list/type_parameter_controller.h index eab3c5585..a2f9c7c9e 100644 --- a/apps/sequence/list/type_parameter_controller.h +++ b/apps/sequence/list/type_parameter_controller.h @@ -14,7 +14,7 @@ public: TableCell::Layout cellLayout, KDCoordinate topMargin = 0, KDCoordinate rightMargin = 0, KDCoordinate bottomMargin = 0, KDCoordinate leftMargin = 0); ~TypeParameterController(); - const char * title() const override; + const char * title() override; View * view() override; void didBecomeFirstResponder() override; bool handleEvent(Ion::Events::Event event) override; diff --git a/apps/sequence/values/values_controller.cpp b/apps/sequence/values/values_controller.cpp index 8ebee56db..94528b628 100644 --- a/apps/sequence/values/values_controller.cpp +++ b/apps/sequence/values/values_controller.cpp @@ -6,7 +6,7 @@ using namespace Shared; namespace Sequence { ValuesController::ValuesController(Responder * parentResponder, SequenceStore * sequenceStore, ButtonRowController * header) : - Shared::ValuesController(parentResponder, header, 'n'), + Shared::ValuesController(parentResponder, header, I18n::Message::NColumn), m_sequenceTitleCells{SequenceTitleCell(FunctionTitleCell::Orientation::HorizontalIndicator), SequenceTitleCell(FunctionTitleCell::Orientation::HorizontalIndicator), SequenceTitleCell(FunctionTitleCell::Orientation::HorizontalIndicator)}, m_sequenceStore(sequenceStore), @@ -23,7 +23,7 @@ void ValuesController::willDisplayCellAtLocation(HighlightCell * cell, int i, in // The cell is the abscissa title cell: if (j == 0 && i == 0) { EvenOddPointerTextCell * mytitleCell = (EvenOddPointerTextCell *)cell; - mytitleCell->setText("n"); + mytitleCell->setMessage(I18n::Message::N); return; } // The cell is a function title cell: @@ -35,11 +35,11 @@ void ValuesController::willDisplayCellAtLocation(HighlightCell * cell, int i, in } } -const char * ValuesController::emptyMessage() { +I18n::Message ValuesController::emptyMessage() { if (m_sequenceStore->numberOfDefinedFunctions() == 0) { - return "Aucune suite"; + return I18n::Message::NoSequence; } - return "Aucune suite selectionnee"; + return I18n::Message::NoActivatedSequence; } int ValuesController::maxNumberOfCells() { diff --git a/apps/sequence/values/values_controller.h b/apps/sequence/values/values_controller.h index 972a45e91..1d2cd84e9 100644 --- a/apps/sequence/values/values_controller.h +++ b/apps/sequence/values/values_controller.h @@ -12,7 +12,7 @@ public: ValuesController(Responder * parentResponder, SequenceStore * sequenceStore, ButtonRowController * header); int numberOfColumns() override; void willDisplayCellAtLocation(HighlightCell * cell, int i, int j) override; - const char * emptyMessage() override; + I18n::Message emptyMessage() override; private: int maxNumberOfCells() override; int maxNumberOfFunctions() override; diff --git a/apps/settings/app.cpp b/apps/settings/app.cpp index c24e4df2d..3a1d8a9be 100644 --- a/apps/settings/app.cpp +++ b/apps/settings/app.cpp @@ -1,10 +1,11 @@ #include "app.h" #include "settings_icon.h" +#include "../i18n.h" namespace Settings { App::App(Container * container) : - ::App(container, &m_stackViewController, "Parametre", "PARAMETRE", ImageStore::SettingsIcon), + ::App(container, &m_stackViewController, I18n::Message::SettingsApp, I18n::Message::SettingsAppCapital, ImageStore::SettingsIcon, I18n::Message::Warning), m_mainController(MainController(nullptr)), m_stackViewController(StackViewController(&m_modalViewController, &m_mainController)) { diff --git a/apps/settings/main_controller.cpp b/apps/settings/main_controller.cpp index 17338ca10..6e6c56678 100644 --- a/apps/settings/main_controller.cpp +++ b/apps/settings/main_controller.cpp @@ -9,20 +9,20 @@ using namespace Poincare; namespace Settings { -const SettingsNode angleChildren[2] = {SettingsNode("Degres "), SettingsNode("Radians ")}; -const SettingsNode FloatDisplayModeChildren[2] = {SettingsNode("Auto "), SettingsNode("Scientifique ")}; -const SettingsNode complexFormatChildren[2] = {SettingsNode("a+ib "), SettingsNode("eitheta ")}; -const SettingsNode languageChildren[3] = {SettingsNode("Anglais "), SettingsNode("Francais "), SettingsNode("Espagnol ")}; +const SettingsNode angleChildren[2] = {SettingsNode(I18n::Message::Degres), SettingsNode(I18n::Message::Radian)}; +const SettingsNode FloatDisplayModeChildren[2] = {SettingsNode(I18n::Message::Auto), SettingsNode(I18n::Message::Scientific)}; +const SettingsNode complexFormatChildren[2] = {SettingsNode(I18n::Message::Default), SettingsNode(I18n::Message::Default)}; +const SettingsNode languageChildren[3] = {SettingsNode(I18n::Message::French), SettingsNode(I18n::Message::English), SettingsNode(I18n::Message::Spanish)}; -const SettingsNode menu[4] = {SettingsNode("Unite d'angles", angleChildren, 2), SettingsNode("Format resultat", FloatDisplayModeChildren, 2), SettingsNode("Format complexe", complexFormatChildren, 2), - SettingsNode("Langue", languageChildren, 3)}; -const SettingsNode model = SettingsNode("Parametres", menu, 4); +const SettingsNode menu[4] = {SettingsNode(I18n::Message::AngleUnit, angleChildren, 2), SettingsNode(I18n::Message::DisplayMode, FloatDisplayModeChildren, 2), SettingsNode(I18n::Message::ComplexFormat, complexFormatChildren, 2), + SettingsNode(I18n::Message::Language, languageChildren, 3)}; +const SettingsNode model = SettingsNode(I18n::Message::SettingsApp, menu, 4); MainController::MainController(Responder * parentResponder) : ViewController(parentResponder), m_cells{PointerTableCellWithChevronAndPointer(KDText::FontSize::Large, KDText::FontSize::Small), PointerTableCellWithChevronAndPointer(KDText::FontSize::Large, KDText::FontSize::Small), PointerTableCellWithChevronAndPointer(KDText::FontSize::Large, KDText::FontSize::Small)}, - m_complexFormatCell(PointerTableCellWithChevronAndExpression(nullptr, KDText::FontSize::Large)), + m_complexFormatCell(PointerTableCellWithChevronAndExpression(I18n::Message::Default, KDText::FontSize::Large)), m_selectableTableView(SelectableTableView(this, this, 1, Metric::CommonTopMargin, Metric::CommonRightMargin, Metric::CommonBottomMargin, Metric::CommonLeftMargin)), m_nodeModel((Node *)&model), @@ -36,8 +36,8 @@ MainController::~MainController() { m_complexFormatLayout = nullptr; } } -const char * MainController::title() const { - return m_nodeModel->label(); +const char * MainController::title() { + return I18n::translate(m_nodeModel->label()); } View * MainController::view() { @@ -103,7 +103,7 @@ int MainController::typeAtLocation(int i, int j) { void MainController::willDisplayCellForIndex(HighlightCell * cell, int index) { PointerTableCell * myCell = (PointerTableCell *)cell; - myCell->setText(m_nodeModel->children(index)->label()); + myCell->setMessage(m_nodeModel->children(index)->label()); if (index == 2) { if (m_complexFormatLayout) { @@ -131,7 +131,7 @@ void MainController::willDisplayCellForIndex(HighlightCell * cell, int index) { myTextCell->setSubtitle(m_nodeModel->children(index)->children((int)Preferences::sharedPreferences()->displayMode())->label()); break; case 3: - myTextCell->setSubtitle(m_nodeModel->children(index)->children((int)GlobalPreferences::sharedGlobalPreferences()->language())->label()); + myTextCell->setSubtitle(m_nodeModel->children(index)->children((int)GlobalPreferences::sharedGlobalPreferences()->language()-1)->label()); break; } } diff --git a/apps/settings/main_controller.h b/apps/settings/main_controller.h index b88bd37a5..79163ddc8 100644 --- a/apps/settings/main_controller.h +++ b/apps/settings/main_controller.h @@ -12,7 +12,7 @@ public: MainController(Responder * parentResponder); ~MainController(); View * view() override; - const char * title() const override; + const char * title() override; bool handleEvent(Ion::Events::Event event) override; void didBecomeFirstResponder() override; int numberOfRows() override; diff --git a/apps/settings/settings_node.h b/apps/settings/settings_node.h index fd7b34e90..527b575d0 100644 --- a/apps/settings/settings_node.h +++ b/apps/settings/settings_node.h @@ -7,7 +7,7 @@ namespace Settings { class SettingsNode : public Node { public: - constexpr SettingsNode(const char * label = nullptr, const SettingsNode * children = nullptr, int numberOfChildren = 0) : + constexpr SettingsNode(I18n::Message label = I18n::Message::Default, const SettingsNode * children = nullptr, int numberOfChildren = 0) : Node(label, numberOfChildren), m_children(children) { diff --git a/apps/settings/sub_controller.cpp b/apps/settings/sub_controller.cpp index aba16af00..6faf688b7 100644 --- a/apps/settings/sub_controller.cpp +++ b/apps/settings/sub_controller.cpp @@ -11,8 +11,8 @@ namespace Settings { SubController::SubController(Responder * parentResponder) : ViewController(parentResponder), - m_cells{PointerTableCell(nullptr, KDText::FontSize::Large), PointerTableCell(nullptr, KDText::FontSize::Large), - PointerTableCell(nullptr, KDText::FontSize::Large)}, + m_cells{PointerTableCell(I18n::Message::Default, KDText::FontSize::Large), PointerTableCell(I18n::Message::Default, KDText::FontSize::Large), + PointerTableCell(I18n::Message::Default, KDText::FontSize::Large)}, m_selectableTableView(SelectableTableView(this, this, 1, Metric::CommonTopMargin, Metric::CommonRightMargin, Metric::CommonBottomMargin, Metric::CommonLeftMargin)), m_nodeModel(nullptr), @@ -37,9 +37,9 @@ SubController::~SubController() { } } -const char * SubController::title() const { +const char * SubController::title() { if (m_nodeModel) { - return m_nodeModel->label(); + return I18n::translate(m_nodeModel->label()); } return ""; } @@ -97,7 +97,7 @@ void SubController::willDisplayCellForIndex(HighlightCell * cell, int index) { return; } PointerTableCell * myCell = (PointerTableCell *)cell; - myCell->setText(m_nodeModel->children(index)->label()); + myCell->setMessage(m_nodeModel->children(index)->label()); } void SubController::setNodeModel(const Node * nodeModel, int preferenceIndex) { @@ -125,7 +125,7 @@ void SubController::setPreferenceAtIndexWithValueIndex(int preferenceIndex, int Preferences::sharedPreferences()->setComplexFormat((Expression::ComplexFormat)valueIndex); break; case 3: - GlobalPreferences::sharedGlobalPreferences()->setLanguage((GlobalPreferences::Language)valueIndex); + GlobalPreferences::sharedGlobalPreferences()->setLanguage((I18n::Language)(valueIndex+1)); break; } } @@ -139,7 +139,7 @@ int SubController::valueIndexAtPreferenceIndex(int preferenceIndex) { case 2: return (int)Preferences::sharedPreferences()->complexFormat(); case 3: - return (int)GlobalPreferences::sharedGlobalPreferences()->language(); + return (int)GlobalPreferences::sharedGlobalPreferences()->language()-1; default: assert(false); return 0; diff --git a/apps/settings/sub_controller.h b/apps/settings/sub_controller.h index d57b6f154..e6a3312d5 100644 --- a/apps/settings/sub_controller.h +++ b/apps/settings/sub_controller.h @@ -11,7 +11,7 @@ public: SubController(Responder * parentResponder); ~SubController(); View * view() override; - const char * title() const override; + const char * title() override; bool handleEvent(Ion::Events::Event event) override; void didBecomeFirstResponder() override; int numberOfRows() override; diff --git a/apps/shared/banner_view.cpp b/apps/shared/banner_view.cpp index 6830c482e..16671d17d 100644 --- a/apps/shared/banner_view.cpp +++ b/apps/shared/banner_view.cpp @@ -15,6 +15,12 @@ void BannerView::setLegendAtIndex(char * text, int index) { layoutSubviews(); } +void BannerView::setMessageAtIndex(I18n::Message text, int index) { + PointerTextView * textView = pointerTextViewAtIndex(index); + textView->setMessage(text); + layoutSubviews(); +} + KDSize BannerView::minimalSizeForOptimalDisplay() const { return KDSize(0, KDText::stringSize(" ", KDText::FontSize::Small).height()*numberOfLines()); } @@ -86,4 +92,8 @@ int BannerView::numberOfLines() const { return lineNumber+1; } +PointerTextView * BannerView::pointerTextViewAtIndex(int i) const { + return nullptr; +} + } diff --git a/apps/shared/banner_view.h b/apps/shared/banner_view.h index c51d3b276..b0b8d0aad 100644 --- a/apps/shared/banner_view.h +++ b/apps/shared/banner_view.h @@ -8,6 +8,7 @@ namespace Shared { class BannerView : public View { public: void setLegendAtIndex(char * text, int index); + void setMessageAtIndex(I18n::Message text, int index); KDSize minimalSizeForOptimalDisplay() const override; private: int numberOfSubviews() const override; @@ -15,6 +16,7 @@ private: void layoutSubviews() override; int numberOfLines() const; virtual TextView * textViewAtIndex(int i) const = 0; + virtual PointerTextView * pointerTextViewAtIndex(int i) const; }; } diff --git a/apps/shared/button_with_separator.cpp b/apps/shared/button_with_separator.cpp index 226983a36..6675a3642 100644 --- a/apps/shared/button_with_separator.cpp +++ b/apps/shared/button_with_separator.cpp @@ -1,7 +1,7 @@ #include "button_with_separator.h" -ButtonWithSeparator::ButtonWithSeparator(Responder * parentResponder, const char * textBody, Invocation invocation) : - Button(parentResponder, textBody, invocation, KDText::FontSize::Large, KDColorBlack) +ButtonWithSeparator::ButtonWithSeparator(Responder * parentResponder, I18n::Message message, Invocation invocation) : + Button(parentResponder, message, invocation, KDText::FontSize::Large, KDColorBlack) { } diff --git a/apps/shared/button_with_separator.h b/apps/shared/button_with_separator.h index 8f1e07d02..e6337b9bb 100644 --- a/apps/shared/button_with_separator.h +++ b/apps/shared/button_with_separator.h @@ -5,7 +5,7 @@ class ButtonWithSeparator : public Button { public: - ButtonWithSeparator(Responder * parentResponder, const char * textBody, Invocation invocation); + ButtonWithSeparator(Responder * parentResponder, I18n::Message textBody, Invocation invocation); void drawRect(KDContext * ctx, KDRect rect) const override; private: constexpr static KDCoordinate k_margin = 5; diff --git a/apps/shared/editable_cell_table_view_controller.cpp b/apps/shared/editable_cell_table_view_controller.cpp index 417f88755..347483fbc 100644 --- a/apps/shared/editable_cell_table_view_controller.cpp +++ b/apps/shared/editable_cell_table_view_controller.cpp @@ -19,7 +19,7 @@ bool EditableCellTableViewController::textFieldDidFinishEditing(TextField * text Context * globalContext = appsContainer->globalContext(); float floatBody = Expression::parse(text)->approximate(*globalContext); if (isnan(floatBody)) { - app()->displayWarning("Valeur non definie"); + app()->displayWarning(I18n::Message::UndefinedValue); return false; } setDataAtLocation(floatBody, m_selectableTableView.selectedColumn(), m_selectableTableView.selectedRow()); diff --git a/apps/shared/float_parameter_controller.cpp b/apps/shared/float_parameter_controller.cpp index d81bcf5d3..194daeb90 100644 --- a/apps/shared/float_parameter_controller.cpp +++ b/apps/shared/float_parameter_controller.cpp @@ -8,7 +8,7 @@ using namespace Poincare; namespace Shared { -FloatParameterController::FloatParameterController(Responder * parentResponder, const char * okButtonText) : +FloatParameterController::FloatParameterController(Responder * parentResponder, I18n::Message okButtonText) : ViewController(parentResponder), m_selectableTableView(SelectableTableView(this, this, 1, Metric::CommonTopMargin, Metric::CommonRightMargin, Metric::CommonBottomMargin, Metric::CommonLeftMargin, this)), @@ -100,7 +100,7 @@ bool FloatParameterController::textFieldDidFinishEditing(TextField * textField, Context * globalContext = appsContainer->globalContext(); float floatBody = Expression::parse(text)->approximate(*globalContext); if (isnan(floatBody) || isinf(floatBody)) { - app()->displayWarning("Valeur non defini"); + app()->displayWarning(I18n::Message::UndefinedValue); return false; } setParameterAtIndex(m_selectableTableView.selectedRow(), floatBody); diff --git a/apps/shared/float_parameter_controller.h b/apps/shared/float_parameter_controller.h index e75ab6dd9..04b4dc0da 100644 --- a/apps/shared/float_parameter_controller.h +++ b/apps/shared/float_parameter_controller.h @@ -12,7 +12,7 @@ namespace Shared { class FloatParameterController : public ViewController, public ListViewDataSource, public SelectableTableViewDelegate, public TextFieldDelegate { public: - FloatParameterController(Responder * parentResponder, const char * okButtonText = "Valider"); + FloatParameterController(Responder * parentResponder, I18n::Message okButtonText = I18n::Message::Ok); View * view() override; void viewWillAppear() override; void didBecomeFirstResponder() override; diff --git a/apps/shared/function_curve_parameter_controller.cpp b/apps/shared/function_curve_parameter_controller.cpp index 902114e3c..3c0db182a 100644 --- a/apps/shared/function_curve_parameter_controller.cpp +++ b/apps/shared/function_curve_parameter_controller.cpp @@ -3,9 +3,9 @@ namespace Shared { -FunctionCurveParameterController::FunctionCurveParameterController(InteractiveCurveViewRange * graphRange, CurveViewCursor * cursor, const char * symbol) : +FunctionCurveParameterController::FunctionCurveParameterController(InteractiveCurveViewRange * graphRange, CurveViewCursor * cursor, I18n::Message symbol) : ViewController(nullptr), - m_goToCell(PointerTableCellWithChevron((char*)"Aller a")), + m_goToCell(PointerTableCellWithChevron(I18n::Message::Goto)), m_selectableTableView(SelectableTableView(this, this, 1, Metric::CommonTopMargin, Metric::CommonRightMargin, Metric::CommonBottomMargin, Metric::CommonLeftMargin)), m_goToParameterController(GoToParameterController(this, graphRange, cursor, symbol)), diff --git a/apps/shared/function_curve_parameter_controller.h b/apps/shared/function_curve_parameter_controller.h index ce16259c7..cf94c5356 100644 --- a/apps/shared/function_curve_parameter_controller.h +++ b/apps/shared/function_curve_parameter_controller.h @@ -11,7 +11,7 @@ namespace Shared { class FunctionCurveParameterController : public ViewController, public SimpleListViewDataSource { public: - FunctionCurveParameterController(InteractiveCurveViewRange * graphRange, CurveViewCursor * cursor, const char * symbol); + FunctionCurveParameterController(InteractiveCurveViewRange * graphRange, CurveViewCursor * cursor, I18n::Message symbol); View * view() override; void didBecomeFirstResponder() override; KDCoordinate cellHeight() override; diff --git a/apps/shared/go_to_parameter_controller.cpp b/apps/shared/go_to_parameter_controller.cpp index 28792c1dd..ecf25e94a 100644 --- a/apps/shared/go_to_parameter_controller.cpp +++ b/apps/shared/go_to_parameter_controller.cpp @@ -4,17 +4,17 @@ namespace Shared { -GoToParameterController::GoToParameterController(Responder * parentResponder, InteractiveCurveViewRange * graphRange, CurveViewCursor * cursor, const char * symbol) : - FloatParameterController(parentResponder, "Valider"), - m_abscisseCell(PointerTableCellWithEditableText(&m_selectableTableView, this, m_draftTextBuffer, (char*)symbol)), +GoToParameterController::GoToParameterController(Responder * parentResponder, InteractiveCurveViewRange * graphRange, CurveViewCursor * cursor, I18n::Message symbol) : + FloatParameterController(parentResponder), + m_abscisseCell(PointerTableCellWithEditableText(&m_selectableTableView, this, m_draftTextBuffer, symbol)), m_graphRange(graphRange), m_cursor(cursor), m_function(nullptr) { } -const char * GoToParameterController::title() const { - return "Aller a"; +const char * GoToParameterController::title() { + return I18n::translate(I18n::Message::Goto); } void GoToParameterController::viewWillAppear() { diff --git a/apps/shared/go_to_parameter_controller.h b/apps/shared/go_to_parameter_controller.h index ff2329b13..4abbc7a58 100644 --- a/apps/shared/go_to_parameter_controller.h +++ b/apps/shared/go_to_parameter_controller.h @@ -11,8 +11,8 @@ namespace Shared { class GoToParameterController : public FloatParameterController { public: - GoToParameterController(Responder * parentResponder, InteractiveCurveViewRange * graphRange, CurveViewCursor * cursor, const char * symbol); - const char * title() const override; + GoToParameterController(Responder * parentResponder, InteractiveCurveViewRange * graphRange, CurveViewCursor * cursor, I18n::Message symbol); + const char * title() override; void viewWillAppear() override; void setFunction(Function * function); int numberOfRows() override; diff --git a/apps/shared/initialisation_parameter_controller.cpp b/apps/shared/initialisation_parameter_controller.cpp index 95f0fa8c5..f011d8a76 100644 --- a/apps/shared/initialisation_parameter_controller.cpp +++ b/apps/shared/initialisation_parameter_controller.cpp @@ -12,8 +12,8 @@ InitialisationParameterController::InitialisationParameterController(Responder * { } -const char * InitialisationParameterController::title() const { - return "Zoom predefini"; +const char * InitialisationParameterController::title() { + return I18n::translate(I18n::Message::PredefinedZoom); } View * InitialisationParameterController::view() { @@ -58,8 +58,8 @@ KDCoordinate InitialisationParameterController::cellHeight() { void InitialisationParameterController::willDisplayCellForIndex(HighlightCell * cell, int index) { PointerTableCell * myCell = (PointerTableCell *)cell; - const char * titles[4] = {"Trigonometrique", "Abscisses entieres", "Orthonorme", "Reglage de base"}; - myCell->setText(titles[index]); + I18n::Message titles[4] = {I18n::Message::Trigonometric, I18n::Message::RoundAbscissa, I18n::Message::Orthonormal, I18n::Message::DefaultSetting}; + myCell->setMessage(titles[index]); } } diff --git a/apps/shared/initialisation_parameter_controller.h b/apps/shared/initialisation_parameter_controller.h index 77b119594..9cb9bd00b 100644 --- a/apps/shared/initialisation_parameter_controller.h +++ b/apps/shared/initialisation_parameter_controller.h @@ -3,6 +3,7 @@ #include #include "interactive_curve_view_range.h" +#include "../i18n.h" namespace Shared { @@ -10,7 +11,7 @@ class InitialisationParameterController : public ViewController, public SimpleLi public: InitialisationParameterController(Responder * parentResponder, Shared::InteractiveCurveViewRange * graphRange); View * view() override; - const char * title() const override; + const char * title() override; bool handleEvent(Ion::Events::Event event) override; void didBecomeFirstResponder() override; int numberOfRows() override; diff --git a/apps/shared/interactive_curve_view_controller.cpp b/apps/shared/interactive_curve_view_controller.cpp index 25a6fb20b..d41f733ac 100644 --- a/apps/shared/interactive_curve_view_controller.cpp +++ b/apps/shared/interactive_curve_view_controller.cpp @@ -14,17 +14,17 @@ InteractiveCurveViewController::InteractiveCurveViewController(Responder * paren m_cursorView(CursorView()), m_rangeParameterController(RangeParameterController(this, interactiveRange)), m_zoomParameterController(ZoomParameterController(this, interactiveRange, curveView)), - m_rangeButton(this, "Axes", Invocation([](void * context, void * sender) { + m_rangeButton(this, I18n::Message::Axis, Invocation([](void * context, void * sender) { InteractiveCurveViewController * graphController = (InteractiveCurveViewController *) context; StackViewController * stack = graphController->stackController(); stack->push(graphController->rangeParameterController()); }, this), KDText::FontSize::Small), - m_zoomButton(this, "Zoom", Invocation([](void * context, void * sender) { + m_zoomButton(this, I18n::Message::Zoom, Invocation([](void * context, void * sender) { InteractiveCurveViewController * graphController = (InteractiveCurveViewController *) context; StackViewController * stack = graphController->stackController(); stack->push(graphController->zoomParameterController()); }, this), KDText::FontSize::Small), - m_defaultInitialisationButton(this, "Initialisation", Invocation([](void * context, void * sender) { + m_defaultInitialisationButton(this, I18n::Message::Initialization, Invocation([](void * context, void * sender) { InteractiveCurveViewController * graphController = (InteractiveCurveViewController *) context; StackViewController * stack = graphController->stackController(); stack->push(graphController->initialisationParameterController()); @@ -32,8 +32,8 @@ InteractiveCurveViewController::InteractiveCurveViewController(Responder * paren { } -const char * InteractiveCurveViewController::title() const { - return "Graphique"; +const char * InteractiveCurveViewController::title() { + return I18n::translate(I18n::Message::GraphTab); } View * InteractiveCurveViewController::view() { diff --git a/apps/shared/interactive_curve_view_controller.h b/apps/shared/interactive_curve_view_controller.h index e7482ed3f..da906691d 100644 --- a/apps/shared/interactive_curve_view_controller.h +++ b/apps/shared/interactive_curve_view_controller.h @@ -16,7 +16,7 @@ class InteractiveCurveViewController : public ViewController, public ButtonRowDe public: InteractiveCurveViewController(Responder * parentResponder, ButtonRowController * header, InteractiveCurveViewRange * interactiveRange, CurveView * curveView); View * view() override; - const char * title() const override; + const char * title() override; bool handleEvent(Ion::Events::Event event) override; void didBecomeFirstResponder() override; diff --git a/apps/shared/interval_parameter_controller.cpp b/apps/shared/interval_parameter_controller.cpp index b4baccc9f..8185a00f7 100644 --- a/apps/shared/interval_parameter_controller.cpp +++ b/apps/shared/interval_parameter_controller.cpp @@ -4,14 +4,14 @@ namespace Shared { IntervalParameterController::IntervalParameterController(Responder * parentResponder, Interval * interval) : - FloatParameterController(parentResponder, "Valider"), + FloatParameterController(parentResponder), m_interval(interval), - m_intervalCells{PointerTableCellWithEditableText(&m_selectableTableView, this, m_draftTextBuffer, nullptr), PointerTableCellWithEditableText(&m_selectableTableView, this, m_draftTextBuffer, nullptr), PointerTableCellWithEditableText(&m_selectableTableView, this, m_draftTextBuffer, nullptr)} + m_intervalCells{PointerTableCellWithEditableText(&m_selectableTableView, this, m_draftTextBuffer, I18n::Message::Default), PointerTableCellWithEditableText(&m_selectableTableView, this, m_draftTextBuffer, I18n::Message::Default), PointerTableCellWithEditableText(&m_selectableTableView, this, m_draftTextBuffer, I18n::Message::Default)} { } -const char * IntervalParameterController::title() const { - return "Regler l'intervalle"; +const char * IntervalParameterController::title() { + return I18n::translate(I18n::Message::IntervalSet); } void IntervalParameterController::viewWillAppear() { @@ -30,8 +30,8 @@ void IntervalParameterController::willDisplayCellForIndex(HighlightCell * cell, return; } PointerTableCellWithEditableText * myCell = (PointerTableCellWithEditableText *)cell; - const char * labels[k_totalNumberOfCell] = {"x Debut", "x Fin", "x Pas"}; - myCell->setText(labels[index]); + I18n::Message labels[k_totalNumberOfCell] = {I18n::Message::XStart, I18n::Message::XEnd, I18n::Message::XStep}; + myCell->setMessage(labels[index]); FloatParameterController::willDisplayCellForIndex(cell, index); } diff --git a/apps/shared/interval_parameter_controller.h b/apps/shared/interval_parameter_controller.h index a3a2da227..f6e107ecd 100644 --- a/apps/shared/interval_parameter_controller.h +++ b/apps/shared/interval_parameter_controller.h @@ -11,7 +11,7 @@ class IntervalParameterController : public Shared::FloatParameterController { public: IntervalParameterController(Responder * parentResponder, Interval * interval); Interval * interval(); - const char * title() const override; + const char * title() override; void viewWillAppear() override; void willDisplayCellForIndex(HighlightCell * cell, int index) override; int numberOfRows() override; diff --git a/apps/shared/list_controller.cpp b/apps/shared/list_controller.cpp index 6d1b74da9..45fe5159a 100644 --- a/apps/shared/list_controller.cpp +++ b/apps/shared/list_controller.cpp @@ -3,18 +3,18 @@ namespace Shared { -ListController::ListController(Responder * parentResponder, FunctionStore * functionStore, ButtonRowController * header, ButtonRowController * footer, const char * text) : +ListController::ListController(Responder * parentResponder, FunctionStore * functionStore, ButtonRowController * header, ButtonRowController * footer, I18n::Message text) : ViewController(parentResponder), ButtonRowDelegate(header, footer), m_selectableTableView(SelectableTableView(this, this, 0, 0, 0, 0, 0, nullptr, false, true)), m_functionStore(functionStore), m_addNewFunction(text), - m_plotButton(this, "Tracer la fonction", Invocation([](void * context, void * sender) { + m_plotButton(this, I18n::Message::Plot, Invocation([](void * context, void * sender) { ListController * list = (ListController *)context; TabViewController * tabController = list->tabController(); tabController->setActiveTab(1); }, this), KDText::FontSize::Small, Palette::PurpleBright), - m_valuesButton(this, "Afficher les valeurs", Invocation([](void * context, void * sender) { + m_valuesButton(this, I18n::Message::DisplayValues, Invocation([](void * context, void * sender) { ListController * list = (ListController *)context; TabViewController * tabController = list->tabController(); tabController->setActiveTab(2); diff --git a/apps/shared/list_controller.h b/apps/shared/list_controller.h index 4330d7d1d..cf6515a62 100644 --- a/apps/shared/list_controller.h +++ b/apps/shared/list_controller.h @@ -5,12 +5,13 @@ #include "function_store.h" #include "list_parameter_controller.h" #include "new_function_cell.h" +#include "../i18n.h" namespace Shared { class ListController : public ViewController, public ButtonRowDelegate, public TableViewDataSource { public: - ListController(Responder * parentResponder, FunctionStore * functionStore, ButtonRowController * header, ButtonRowController * footer, const char * text); + ListController(Responder * parentResponder, FunctionStore * functionStore, ButtonRowController * header, ButtonRowController * footer, I18n::Message text); View * view() override; int numberOfColumns() override; KDCoordinate columnWidth(int i) override; diff --git a/apps/shared/list_parameter_controller.cpp b/apps/shared/list_parameter_controller.cpp index c12824e83..8dc9318ec 100644 --- a/apps/shared/list_parameter_controller.cpp +++ b/apps/shared/list_parameter_controller.cpp @@ -3,19 +3,19 @@ namespace Shared { -ListParameterController::ListParameterController(Responder * parentResponder, FunctionStore * functionStore) : +ListParameterController::ListParameterController(Responder * parentResponder, FunctionStore * functionStore, I18n::Message functionColorMessage, I18n::Message deleteFunctionMessage) : ViewController(parentResponder), m_selectableTableView(SelectableTableView(this, this, 1, Metric::CommonTopMargin, Metric::CommonRightMargin, Metric::CommonBottomMargin, Metric::CommonLeftMargin)), m_functionStore(functionStore), - m_colorCell(PointerTableCellWithChevron((char*)"Couleur de la fonction")), - m_enableCell(PointerTableCellWithSwitch((char*)"Activer/Desactiver")), - m_deleteCell(PointerTableCell((char*)"Supprimer la fonction")) + m_colorCell(PointerTableCellWithChevron(functionColorMessage)), + m_enableCell(PointerTableCellWithSwitch(I18n::Message::ActivateDesactivate)), + m_deleteCell(PointerTableCell(deleteFunctionMessage)) { } -const char * ListParameterController::title() const { - return "Options de la fonction"; +const char * ListParameterController::title() { + return I18n::translate(I18n::Message::FunctionOptions); } View * ListParameterController::view() { @@ -93,8 +93,8 @@ bool ListParameterController::handleEnterOnRow(int rowIndex) { stack->pop(); return true; } - app()->displayWarning("Pas de fonction a supprimer"); - return false; + app()->displayWarning(I18n::Message::NoFunctionToDelete); + return true; } } default: diff --git a/apps/shared/list_parameter_controller.h b/apps/shared/list_parameter_controller.h index ec08733e6..b1680451c 100644 --- a/apps/shared/list_parameter_controller.h +++ b/apps/shared/list_parameter_controller.h @@ -4,15 +4,16 @@ #include #include "function.h" #include "function_store.h" +#include "../i18n.h" namespace Shared { class ListParameterController : public ViewController, public SimpleListViewDataSource { public: - ListParameterController(Responder * parentResponder, FunctionStore * functionStore); + ListParameterController(Responder * parentResponder, FunctionStore * functionStore, I18n::Message functionColorMessage, I18n::Message deleteFunctionMessage); View * view() override; - const char * title() const override; + const char * title() override; bool handleEvent(Ion::Events::Event event) override; virtual void setFunction(Function * function); void didBecomeFirstResponder() override; diff --git a/apps/shared/new_function_cell.cpp b/apps/shared/new_function_cell.cpp index 12bd6b4d5..f684c37b5 100644 --- a/apps/shared/new_function_cell.cpp +++ b/apps/shared/new_function_cell.cpp @@ -3,7 +3,7 @@ namespace Shared { -NewFunctionCell::NewFunctionCell(const char * text) : +NewFunctionCell::NewFunctionCell(I18n::Message text) : EvenOddCell(), m_pointerTextView(PointerTextView(KDText::FontSize::Large, text, 0.5f, 0.5f)) { diff --git a/apps/shared/new_function_cell.h b/apps/shared/new_function_cell.h index 9b576e9d4..b58fd0c23 100644 --- a/apps/shared/new_function_cell.h +++ b/apps/shared/new_function_cell.h @@ -7,7 +7,7 @@ namespace Shared { class NewFunctionCell : public EvenOddCell { public: - NewFunctionCell(const char * text); + NewFunctionCell(I18n::Message text); void reloadCell() override; int numberOfSubviews() const override; View * subviewAtIndex(int index) override; diff --git a/apps/shared/range_parameter_controller.cpp b/apps/shared/range_parameter_controller.cpp index a19c7d856..553add6fe 100644 --- a/apps/shared/range_parameter_controller.cpp +++ b/apps/shared/range_parameter_controller.cpp @@ -8,16 +8,16 @@ using namespace Poincare; namespace Shared { RangeParameterController::RangeParameterController(Responder * parentResponder, InteractiveCurveViewRange * interactiveRange) : - FloatParameterController(parentResponder, "Valider"), + FloatParameterController(parentResponder), m_interactiveRange(interactiveRange), - m_rangeCells{PointerTableCellWithEditableText(&m_selectableTableView, this, m_draftTextBuffer, nullptr), PointerTableCellWithEditableText(&m_selectableTableView, this, m_draftTextBuffer, nullptr), - PointerTableCellWithEditableText(&m_selectableTableView, this, m_draftTextBuffer, nullptr), PointerTableCellWithEditableText(&m_selectableTableView, this, m_draftTextBuffer, nullptr)}, - m_yAutoCell(PointerTableCellWithSwitch((char*)"Y auto")) + m_rangeCells{PointerTableCellWithEditableText(&m_selectableTableView, this, m_draftTextBuffer, I18n::Message::Default), PointerTableCellWithEditableText(&m_selectableTableView, this, m_draftTextBuffer, I18n::Message::Default), + PointerTableCellWithEditableText(&m_selectableTableView, this, m_draftTextBuffer, I18n::Message::Default), PointerTableCellWithEditableText(&m_selectableTableView, this, m_draftTextBuffer, I18n::Message::Default)}, + m_yAutoCell(PointerTableCellWithSwitch(I18n::Message::YAuto)) { } -const char * RangeParameterController::title() const { - return "Axes"; +const char * RangeParameterController::title() { + return I18n::translate(I18n::Message::Axis); } void RangeParameterController::viewWillAppear() { @@ -53,8 +53,8 @@ void RangeParameterController::willDisplayCellForIndex(HighlightCell * cell, int return; } PointerTableCellWithEditableText * myCell = (PointerTableCellWithEditableText *)cell; - const char * labels[k_numberOfTextCell+1] = {"Xmin", "Xmax", "", "Ymin", "Ymax"}; - myCell->setText(labels[index]); + I18n::Message labels[k_numberOfTextCell+1] = {I18n::Message::XMin, I18n::Message::XMax, I18n::Message::Default, I18n::Message::YMin, I18n::Message::YMax}; + myCell->setMessage(labels[index]); KDColor yColor = m_interactiveRange->yAuto() ? Palette::GreyDark : KDColorBlack; KDColor colors[k_numberOfTextCell+1] = {KDColorBlack, KDColorBlack, KDColorBlack, yColor, yColor}; myCell->setTextColor(colors[index]); diff --git a/apps/shared/range_parameter_controller.h b/apps/shared/range_parameter_controller.h index 706e72749..6007d4003 100644 --- a/apps/shared/range_parameter_controller.h +++ b/apps/shared/range_parameter_controller.h @@ -10,7 +10,7 @@ namespace Shared { class RangeParameterController : public FloatParameterController { public: RangeParameterController(Responder * parentResponder, InteractiveCurveViewRange * interactiveCurveViewRange); - const char * title() const override; + const char * title() override; void viewWillAppear() override; int numberOfRows() override; int typeAtLocation(int i, int j) override; diff --git a/apps/shared/store_controller.cpp b/apps/shared/store_controller.cpp index 46402bbe3..48f5f28c9 100644 --- a/apps/shared/store_controller.cpp +++ b/apps/shared/store_controller.cpp @@ -20,8 +20,8 @@ StoreController::StoreController(Responder * parentResponder, FloatPairStore * s { } -const char * StoreController::title() const { - return "Donnees"; +const char * StoreController::title() { + return I18n::translate(I18n::Message::DataTab); } int StoreController::numberOfColumns() { diff --git a/apps/shared/store_controller.h b/apps/shared/store_controller.h index 194e920e7..a1204d60b 100644 --- a/apps/shared/store_controller.h +++ b/apps/shared/store_controller.h @@ -11,7 +11,7 @@ namespace Shared { class StoreController : public EditableCellTableViewController, public ButtonRowDelegate { public: StoreController(Responder * parentResponder, FloatPairStore * store, ButtonRowController * header); - const char * title() const override; + const char * title() override; int numberOfColumns() override; KDCoordinate columnWidth(int i) override; KDCoordinate cumulatedWidthFromIndex(int i) override; diff --git a/apps/shared/store_parameter_controller.cpp b/apps/shared/store_parameter_controller.cpp index 9ea48e42f..b741a4d32 100644 --- a/apps/shared/store_parameter_controller.cpp +++ b/apps/shared/store_parameter_controller.cpp @@ -5,9 +5,9 @@ namespace Shared { StoreParameterController::StoreParameterController(Responder * parentResponder, FloatPairStore * store) : ViewController(parentResponder), - m_deleteColumn(PointerTableCell((char*)"Effacer la colonne")), - m_copyColumn(PointerTableCellWithChevron((char*)"Copier la colonne dans une liste")), - m_importList(PointerTableCellWithChevron((char*)"Importer une liste")), + m_deleteColumn(PointerTableCell(I18n::Message::ClearColumn)), + m_copyColumn(PointerTableCellWithChevron(I18n::Message::CopyColumnInList)), + m_importList(PointerTableCellWithChevron(I18n::Message::ImportList)), m_selectableTableView(SelectableTableView(this, this, 1, Metric::CommonTopMargin, Metric::CommonRightMargin, Metric::CommonBottomMargin, Metric::CommonLeftMargin)), m_store(store), @@ -19,8 +19,8 @@ void StoreParameterController::selectXColumn(bool xColumnSelected) { m_xColumnSelected = xColumnSelected; } -const char * StoreParameterController::title() const { - return "Option de la colonne"; +const char * StoreParameterController::title() { + return I18n::translate(I18n::Message::ColumnOptions); } View * StoreParameterController::view() { diff --git a/apps/shared/store_parameter_controller.h b/apps/shared/store_parameter_controller.h index def1a32ac..69bc36826 100644 --- a/apps/shared/store_parameter_controller.h +++ b/apps/shared/store_parameter_controller.h @@ -3,6 +3,7 @@ #include #include "float_pair_store.h" +#include "../i18n.h" namespace Shared { @@ -11,7 +12,7 @@ public: StoreParameterController(Responder * parentResponder, FloatPairStore * store); void selectXColumn(bool xColumnSelected); View * view() override; - const char * title() const override; + const char * title() override; bool handleEvent(Ion::Events::Event event) override; void didBecomeFirstResponder() override; int numberOfRows() override; diff --git a/apps/shared/text_field_delegate_app.cpp b/apps/shared/text_field_delegate_app.cpp index a97464dd4..c6e7f3b7f 100644 --- a/apps/shared/text_field_delegate_app.cpp +++ b/apps/shared/text_field_delegate_app.cpp @@ -7,9 +7,8 @@ using namespace Poincare; namespace Shared { -TextFieldDelegateApp::TextFieldDelegateApp(Container * container, ViewController * rootViewController, const char * name, - const char * upperName, const Image * icon) : - ::App(container, rootViewController, name, upperName, icon), +TextFieldDelegateApp::TextFieldDelegateApp(Container * container, ViewController * rootViewController, I18n::Message name, I18n::Message upperName, const Image * icon) : + ::App(container, rootViewController, name, upperName, icon, I18n::Message::Warning), TextFieldDelegate() { } @@ -51,13 +50,13 @@ bool TextFieldDelegateApp::textFieldDidReceiveEvent(TextField * textField, Ion:: if (textField->textLength() == 0) { return true; } - textField->app()->displayWarning("Attention a la syntaxe jeune padawan"); + textField->app()->displayWarning(I18n::Message::SyntaxError); return true; } Expression * evaluation = exp->evaluate(*localContext()); if (evaluation == nullptr) { delete exp; - textField->app()->displayWarning("Relis ton cours de maths, veux tu?"); + textField->app()->displayWarning(I18n::Message::MathError); return true; } else { delete evaluation; diff --git a/apps/shared/text_field_delegate_app.h b/apps/shared/text_field_delegate_app.h index a29ed79af..d12e71911 100644 --- a/apps/shared/text_field_delegate_app.h +++ b/apps/shared/text_field_delegate_app.h @@ -3,6 +3,7 @@ #include #include +#include "../i18n.h" class AppsContainer; @@ -10,7 +11,7 @@ namespace Shared { class TextFieldDelegateApp : public ::App, public TextFieldDelegate { public: - TextFieldDelegateApp(Container * container, ViewController * rootViewController, const char * name = nullptr, const char * upperName = nullptr, const Image * icon = nullptr); + TextFieldDelegateApp(Container * container, ViewController * rootViewController, I18n::Message name = (I18n::Message)0, I18n::Message upperName = (I18n::Message)0, const Image * icon = nullptr); virtual Poincare::Context * localContext(); AppsContainer * container(); virtual const char * XNT(); diff --git a/apps/shared/values_controller.cpp b/apps/shared/values_controller.cpp index 31d7c0df1..536e20949 100644 --- a/apps/shared/values_controller.cpp +++ b/apps/shared/values_controller.cpp @@ -8,7 +8,7 @@ using namespace Poincare; namespace Shared { -ValuesController::ValuesController(Responder * parentResponder, ButtonRowController * header, char symbol) : +ValuesController::ValuesController(Responder * parentResponder, ButtonRowController * header, I18n::Message parameterTitle) : EditableCellTableViewController(parentResponder, k_topMargin, k_rightMargin, k_bottomMargin, k_leftMargin), ButtonRowDelegate(header, nullptr), m_abscissaTitleCell(EvenOddPointerTextCell(KDText::FontSize::Small)), @@ -16,8 +16,8 @@ ValuesController::ValuesController(Responder * parentResponder, ButtonRowControl EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer, KDText::FontSize::Small), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer, KDText::FontSize::Small), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer, KDText::FontSize::Small), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer, KDText::FontSize::Small), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer, KDText::FontSize::Small), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer, KDText::FontSize::Small)}, m_intervalParameterController(IntervalParameterController(this, &m_interval)), - m_abscissaParameterController(ValuesParameterController(this, &m_intervalParameterController, symbol)), - m_setIntervalButton(Button(this, "Regler l'intervalle",Invocation([](void * context, void * sender) { + m_abscissaParameterController(ValuesParameterController(this, &m_intervalParameterController, parameterTitle)), + m_setIntervalButton(Button(this, I18n::Message::IntervalSet, Invocation([](void * context, void * sender) { ValuesController * valuesController = (ValuesController *) context; StackViewController * stack = ((StackViewController *)valuesController->stackController()); stack->push(valuesController->intervalParameterController()); @@ -28,8 +28,8 @@ ValuesController::ValuesController(Responder * parentResponder, ButtonRowControl m_interval.setStep(1); } -const char * ValuesController::title() const { - return "Valeurs"; +const char * ValuesController::title() { + return I18n::translate(I18n::Message::ValuesTab); } Interval * ValuesController::interval() { diff --git a/apps/shared/values_controller.h b/apps/shared/values_controller.h index 9b16466bb..b713f9744 100644 --- a/apps/shared/values_controller.h +++ b/apps/shared/values_controller.h @@ -9,13 +9,14 @@ #include "values_parameter_controller.h" #include "values_function_parameter_controller.h" #include "interval_parameter_controller.h" +#include "../i18n.h" namespace Shared { class ValuesController : public EditableCellTableViewController, public ButtonRowDelegate, public AlternateEmptyViewDelegate { public: - ValuesController(Responder * parentResponder, ButtonRowController * header, char symbol); - const char * title() const override; + ValuesController(Responder * parentResponder, ButtonRowController * header, I18n::Message parameterTitle); + const char * title() override; Interval * interval(); virtual bool handleEvent(Ion::Events::Event event) override; void didBecomeFirstResponder() override; diff --git a/apps/shared/values_function_parameter_controller.cpp b/apps/shared/values_function_parameter_controller.cpp index f20625f6d..29fdbf100 100644 --- a/apps/shared/values_function_parameter_controller.cpp +++ b/apps/shared/values_function_parameter_controller.cpp @@ -5,21 +5,23 @@ namespace Shared { ValuesFunctionParameterController::ValuesFunctionParameterController(char symbol) : ViewController(nullptr), - m_copyColumn(PointerTableCellWithChevron((char*)"Copier la colonne dans une liste")), + m_copyColumn(PointerTableCellWithChevron(I18n::Message::CopyColumnInList)), m_selectableTableView(SelectableTableView(this, this, 1, Metric::CommonTopMargin, Metric::CommonRightMargin, Metric::CommonBottomMargin, Metric::CommonLeftMargin)), - m_pageTitle{"Colonne f(x)"}, - m_function(nullptr) + m_function(nullptr), + m_symbol(symbol) { - for (int currentChar = 0; currentChar < k_maxNumberOfCharsInTitle; currentChar++) { - if (m_pageTitle[currentChar] == '(') { - m_pageTitle[currentChar+1] = symbol; - return; - } - } } -const char * ValuesFunctionParameterController::title() const { +const char * ValuesFunctionParameterController::title() { + strlcpy(m_pageTitle, I18n::translate(I18n::Message::FunctionColumn), k_maxNumberOfCharsInTitle); + for (int currentChar = 0; currentChar < k_maxNumberOfCharsInTitle; currentChar++) { + if (m_pageTitle[currentChar] == '(') { + m_pageTitle[currentChar-1] = *m_function->name(); + m_pageTitle[currentChar+1] = m_symbol; + break; + } + } return m_pageTitle; } @@ -29,12 +31,6 @@ View * ValuesFunctionParameterController::view() { void ValuesFunctionParameterController::setFunction(Function * function) { m_function = function; - for (int currentChar = 0; currentChar < k_maxNumberOfCharsInTitle; currentChar++) { - if (m_pageTitle[currentChar] == '(') { - m_pageTitle[currentChar-1] = *m_function->name(); - return; - } - } } void ValuesFunctionParameterController::didBecomeFirstResponder() { @@ -49,7 +45,7 @@ int ValuesFunctionParameterController::numberOfRows() { HighlightCell * ValuesFunctionParameterController::reusableCell(int index) { assert(index == 0); - return &m_copyColumn; + return &m_copyColumn; } int ValuesFunctionParameterController::reusableCellCount() { diff --git a/apps/shared/values_function_parameter_controller.h b/apps/shared/values_function_parameter_controller.h index 3b47dbbd1..14e33566e 100644 --- a/apps/shared/values_function_parameter_controller.h +++ b/apps/shared/values_function_parameter_controller.h @@ -3,6 +3,7 @@ #include #include "function.h" +#include "../i18n.h" namespace Shared { @@ -11,7 +12,7 @@ public: ValuesFunctionParameterController(char symbol); View * view() override; - const char * title() const override; + const char * title() override; void didBecomeFirstResponder() override; virtual int numberOfRows() override; KDCoordinate cellHeight() override; @@ -25,6 +26,7 @@ private: constexpr static int k_maxNumberOfCharsInTitle = 16; char m_pageTitle[k_maxNumberOfCharsInTitle]; Function * m_function; + char m_symbol; }; } diff --git a/apps/shared/values_parameter_controller.cpp b/apps/shared/values_parameter_controller.cpp index 1dd0db71e..44f8362fb 100644 --- a/apps/shared/values_parameter_controller.cpp +++ b/apps/shared/values_parameter_controller.cpp @@ -3,26 +3,20 @@ namespace Shared { -ValuesParameterController::ValuesParameterController(Responder * parentResponder, IntervalParameterController * intervalParameterController, char symbol) : +ValuesParameterController::ValuesParameterController(Responder * parentResponder, IntervalParameterController * intervalParameterController, I18n::Message title) : ViewController(parentResponder), - m_pageTitle("Colonne 0"), - m_deleteColumn(PointerTableCell((char*)"Effacer la colonne")), - m_copyColumn(PointerTableCellWithChevron((char*)"Copier la colonne dans une liste")), - m_setInterval(PointerTableCellWithChevron((char*)"Regler l'intervalle")), + m_pageTitle(title), + m_deleteColumn(PointerTableCell(I18n::Message::ClearColumn)), + m_copyColumn(PointerTableCellWithChevron(I18n::Message::CopyColumnInList)), + m_setInterval(PointerTableCellWithChevron(I18n::Message::IntervalSet)), m_selectableTableView(SelectableTableView(this, this, 1, Metric::CommonTopMargin, Metric::CommonRightMargin, Metric::CommonBottomMargin, Metric::CommonLeftMargin)), m_intervalParameterController(intervalParameterController) { - for (int currentChar = 0; currentChar < k_maxNumberOfCharsInTitle; currentChar++) { - if (m_pageTitle[currentChar] == ' ') { - m_pageTitle[currentChar+1] = symbol; - return; - } - } } -const char * ValuesParameterController::title() const { - return m_pageTitle; +const char * ValuesParameterController::title() { + return I18n::translate(m_pageTitle); } View * ValuesParameterController::view() { diff --git a/apps/shared/values_parameter_controller.h b/apps/shared/values_parameter_controller.h index 45148814e..c4087f1a9 100644 --- a/apps/shared/values_parameter_controller.h +++ b/apps/shared/values_parameter_controller.h @@ -7,10 +7,10 @@ namespace Shared { class ValuesParameterController : public ViewController, public SimpleListViewDataSource { public: - ValuesParameterController(Responder * parentResponder, IntervalParameterController * intervalParameterController, char symbol); + ValuesParameterController(Responder * parentResponder, IntervalParameterController * intervalParameterController, I18n::Message title); View * view() override; - const char * title() const override; + const char * title() override; bool handleEvent(Ion::Events::Event event) override; void didBecomeFirstResponder() override; int numberOfRows() override; @@ -19,8 +19,7 @@ public: int reusableCellCount() override; private: constexpr static int k_totalNumberOfCell = 3; - constexpr static int k_maxNumberOfCharsInTitle = 10; - char m_pageTitle[10]; + I18n::Message m_pageTitle; PointerTableCell m_deleteColumn; PointerTableCellWithChevron m_copyColumn; PointerTableCellWithChevron m_setInterval; diff --git a/apps/shared/zoom_parameter_controller.cpp b/apps/shared/zoom_parameter_controller.cpp index db4e3fdd8..d89681bce 100644 --- a/apps/shared/zoom_parameter_controller.cpp +++ b/apps/shared/zoom_parameter_controller.cpp @@ -11,8 +11,8 @@ ZoomParameterController::ZoomParameterController(Responder * parentResponder, In { } -const char * ZoomParameterController::title() const { - return "Zoom interactif"; +const char * ZoomParameterController::title() { + return I18n::translate(I18n::Message::InteractiveZoom); } View * ZoomParameterController::view() { @@ -93,11 +93,11 @@ CurveView * ZoomParameterController::ContentView::curveView() { /* Legend View */ ZoomParameterController::ContentView::LegendView::LegendView() : - m_legends{PointerTextView(KDText::FontSize::Small, "HAUT", 0.0f, 0.5f, KDColorBlack, Palette::GreyBright), - PointerTextView(KDText::FontSize::Small, "GAUCHE", 0.0f, 0.5f, KDColorBlack, Palette::GreyBright), - PointerTextView(KDText::FontSize::Small, "ZOOM", 0.5f, 0.5f, KDColorBlack, Palette::GreyBright), - PointerTextView(KDText::FontSize::Small, "BAS", 1.0f, 0.5f, KDColorBlack, Palette::GreyBright), - PointerTextView(KDText::FontSize::Small, "DROITE", 1.0f, 0.5f, KDColorBlack, Palette::GreyBright)}, + m_legends{PointerTextView(KDText::FontSize::Small, I18n::Message::TopCapital, 0.0f, 0.5f, KDColorBlack, Palette::GreyBright), + PointerTextView(KDText::FontSize::Small, I18n::Message::LeftCapital, 0.0f, 0.5f, KDColorBlack, Palette::GreyBright), + PointerTextView(KDText::FontSize::Small, I18n::Message::ZoomCapital, 0.5f, 0.5f, KDColorBlack, Palette::GreyBright), + PointerTextView(KDText::FontSize::Small, I18n::Message::BottomCapital, 1.0f, 0.5f, KDColorBlack, Palette::GreyBright), + PointerTextView(KDText::FontSize::Small, I18n::Message::RightCapital, 1.0f, 0.5f, KDColorBlack, Palette::GreyBright)}, m_legendPictograms{KeyView(KeyView::Type::Up), KeyView(KeyView::Type::Left), KeyView(KeyView::Type::Plus), KeyView(KeyView::Type::Minus), KeyView(KeyView::Type::Down), KeyView(KeyView::Type::Right)} diff --git a/apps/shared/zoom_parameter_controller.h b/apps/shared/zoom_parameter_controller.h index 49ce35f88..19c949ea5 100644 --- a/apps/shared/zoom_parameter_controller.h +++ b/apps/shared/zoom_parameter_controller.h @@ -4,13 +4,14 @@ #include #include "interactive_curve_view_range.h" #include "curve_view.h" +#include "../i18n.h" namespace Shared { class ZoomParameterController : public ViewController { public: ZoomParameterController(Responder * parentResponder, InteractiveCurveViewRange * interactiveCurveViewRange, CurveView * curveView); - const char * title() const override; + const char * title() override; View * view() override; bool handleEvent(Ion::Events::Event event) override; void viewWillAppear() override; diff --git a/apps/statistics/app.cpp b/apps/statistics/app.cpp index 8bf0818e9..f3e2274a5 100644 --- a/apps/statistics/app.cpp +++ b/apps/statistics/app.cpp @@ -6,7 +6,7 @@ using namespace Shared; namespace Statistics { App::App(Container * container) : - TextFieldDelegateApp(container, &m_tabViewController, "Statistiques", "STATISTIQUES", ImageStore::StatIcon), + TextFieldDelegateApp(container, &m_tabViewController, I18n::Message::StatsApp, I18n::Message::StatsAppCapital, ImageStore::StatIcon), m_store(), m_calculationController(CalculationController(&m_calculationAlternateEmptyViewController, &m_calculationHeader, &m_store)), m_calculationAlternateEmptyViewController(AlternateEmptyViewController(&m_calculationHeader, &m_calculationController, &m_calculationController)), diff --git a/apps/statistics/box_banner_view.cpp b/apps/statistics/box_banner_view.cpp index fe21b8b23..257d151ee 100644 --- a/apps/statistics/box_banner_view.cpp +++ b/apps/statistics/box_banner_view.cpp @@ -3,7 +3,7 @@ namespace Statistics { BoxBannerView::BoxBannerView() : - m_calculationName(KDText::FontSize::Small, nullptr, 0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle), + m_calculationName(KDText::FontSize::Small, I18n::Message::Minimum, 0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle), m_calculationValue(KDText::FontSize::Small, 1.0f, 0.5f, KDColorBlack, Palette::GreyMiddle) { } @@ -17,4 +17,11 @@ TextView * BoxBannerView::textViewAtIndex(int index) const { return (TextView *)textViews[index]; } +PointerTextView * BoxBannerView::pointerTextViewAtIndex(int index) const { + if (index == 0) { + return (PointerTextView *)&m_calculationName; + } + return nullptr; +} + } diff --git a/apps/statistics/box_banner_view.h b/apps/statistics/box_banner_view.h index 66cbaec87..4613e9cbf 100644 --- a/apps/statistics/box_banner_view.h +++ b/apps/statistics/box_banner_view.h @@ -3,6 +3,7 @@ #include #include "../shared/banner_view.h" +#include "../i18n.h" namespace Statistics { @@ -12,6 +13,7 @@ public: private: int numberOfSubviews() const override; TextView * textViewAtIndex(int i) const override; + PointerTextView * pointerTextViewAtIndex(int i) const override; PointerTextView m_calculationName; BufferTextView m_calculationValue; }; diff --git a/apps/statistics/box_controller.cpp b/apps/statistics/box_controller.cpp index 1bbd8df32..d200d5856 100644 --- a/apps/statistics/box_controller.cpp +++ b/apps/statistics/box_controller.cpp @@ -16,8 +16,8 @@ BoxController::BoxController(Responder * parentResponder, ButtonRowController * { } -const char * BoxController::title() const { - return "Boite"; +const char * BoxController::title() { + return I18n::translate(I18n::Message::BoxTab); } View * BoxController::view() { @@ -52,8 +52,9 @@ bool BoxController::isEmpty() const { } return false; } -const char * BoxController::emptyMessage() { - return "Aucune donnee a tracer"; + +I18n::Message BoxController::emptyMessage() { + return I18n::Message::NoDataToPlot; } Responder * BoxController::defaultController() { @@ -65,8 +66,8 @@ Responder * BoxController::tabController() const { } void BoxController::reloadBannerView() { - const char * calculationName[5] = {"Minimum", "Premier quartile", "Mediane", "Troisieme quartile", "Maximum"}; - m_boxBannerView.setLegendAtIndex((char *)calculationName[(int)m_view.selectedQuantile()], 0); + I18n::Message calculationName[5] = {I18n::Message::Minimum, I18n::Message::FirstQuartile, I18n::Message::Median, I18n::Message::ThirdQuartile, I18n::Message::Maximum}; + m_boxBannerView.setMessageAtIndex(calculationName[(int)m_view.selectedQuantile()], 0); char buffer[Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)]; CalculPointer calculationMethods[5] = {&Store::minValue, &Store::firstQuartile, &Store::median, &Store::thirdQuartile, &Store::maxValue}; diff --git a/apps/statistics/box_controller.h b/apps/statistics/box_controller.h index a641d3955..1c4adb95e 100644 --- a/apps/statistics/box_controller.h +++ b/apps/statistics/box_controller.h @@ -11,12 +11,12 @@ namespace Statistics { class BoxController : public ViewController, public ButtonRowDelegate, public AlternateEmptyViewDelegate { public: BoxController(Responder * parentResponder, ButtonRowController * header, Store * store); - const char * title() const override; + const char * title() override; View * view() override; bool handleEvent(Ion::Events::Event event) override; void didBecomeFirstResponder() override; bool isEmpty() const override; - const char * emptyMessage() override; + I18n::Message emptyMessage() override; Responder * defaultController() override; void viewWillAppear() override; void willExitResponderChain(Responder * nextFirstResponder) override; diff --git a/apps/statistics/calculation_controller.cpp b/apps/statistics/calculation_controller.cpp index 7b8fd715f..7ba2a32a5 100644 --- a/apps/statistics/calculation_controller.cpp +++ b/apps/statistics/calculation_controller.cpp @@ -25,8 +25,8 @@ CalculationController::CalculationController(Responder * parentResponder, Button } } -const char * CalculationController::title() const { - return "Stats"; +const char * CalculationController::title() { + return I18n::translate(I18n::Message::StatTab); } bool CalculationController::handleEvent(Ion::Events::Event event) { @@ -54,8 +54,8 @@ bool CalculationController::isEmpty() const { return false; } -const char * CalculationController::emptyMessage() { - return "Aucune grandeur a calculer"; +I18n::Message CalculationController::emptyMessage() { + return I18n::Message::NoValueToCompute; } Responder * CalculationController::defaultController() { @@ -75,11 +75,9 @@ void CalculationController::willDisplayCellAtLocation(HighlightCell * cell, int myCell->setEven(j%2 == 0); myCell->setHighlighted(i == m_selectableTableView.selectedColumn() && j == m_selectableTableView.selectedRow()); if (i == 0) { - const char * titles[k_totalNumberOfRows] = {"Effectif total", "Minimum", "Maximum", "Etendue", - "Moyenne", "Ecart-type", "Variance", "Q1", "Q3", "Mediane", "Ecart interquartile", "Somme", - "Somme des carres"}; + I18n::Message titles[k_totalNumberOfRows] = {I18n::Message::TotalSize, I18n::Message::Minimum, I18n::Message::Maximum, I18n::Message::Range, I18n::Message::Mean, I18n::Message::StandardDeviation, I18n::Message::Deviation, I18n::Message::FirstQuartile, I18n::Message::ThirdQuartile, I18n::Message::Median, I18n::Message::InterquartileRange, I18n::Message::Sum, I18n::Message::SquareSum}; EvenOddPointerTextCell * myCell = (EvenOddPointerTextCell *)cell; - myCell->setText(titles[j]); + myCell->setMessage(titles[j]); } else { CalculPointer calculationMethods[k_totalNumberOfRows] = {&Store::sumOfOccurrences, &Store::minValue, &Store::maxValue, &Store::range, &Store::mean, &Store::standardDeviation, &Store::variance, &Store::firstQuartile, diff --git a/apps/statistics/calculation_controller.h b/apps/statistics/calculation_controller.h index 62f667cb7..4749149de 100644 --- a/apps/statistics/calculation_controller.h +++ b/apps/statistics/calculation_controller.h @@ -12,12 +12,12 @@ class CalculationController : public Shared::TabTableController, public ButtonRo public: CalculationController(Responder * parentResponder, ButtonRowController * header, Store * store); - const char * title() const override; + const char * title() override; bool handleEvent(Ion::Events::Event event) override; void didBecomeFirstResponder() override; bool isEmpty() const override; - const char * emptyMessage() override; + I18n::Message emptyMessage() override; Responder * defaultController() override; int numberOfRows() override; diff --git a/apps/statistics/histogram_banner_view.cpp b/apps/statistics/histogram_banner_view.cpp index 5c4223885..53c193246 100644 --- a/apps/statistics/histogram_banner_view.cpp +++ b/apps/statistics/histogram_banner_view.cpp @@ -6,19 +6,27 @@ namespace Statistics { HistogramBannerView::HistogramBannerView() : - m_intervalView(KDText::FontSize::Small, 0.5f, 0.5f, KDColorBlack, Palette::GreyMiddle), - m_sizeView(KDText::FontSize::Small, 0.5f, 0.5f, KDColorBlack, Palette::GreyMiddle), - m_frequencyView(KDText::FontSize::Small, 0.5f, 0.5f, KDColorBlack, Palette::GreyMiddle) + m_intervalLegendView(KDText::FontSize::Small, I18n::Message::Interval, 1.0f, 0.5f, KDColorBlack, Palette::GreyMiddle), + m_intervalView(KDText::FontSize::Small, 0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle), + m_sizeLegendView(KDText::FontSize::Small, I18n::Message::Size, 1.0f, 0.5f, KDColorBlack, Palette::GreyMiddle), + m_sizeView(KDText::FontSize::Small, 0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle), + m_frequencyLegendView(KDText::FontSize::Small, I18n::Message::Frequency, 1.0f, 0.5f, KDColorBlack, Palette::GreyMiddle), + m_frequencyView(KDText::FontSize::Small, 0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle) { } int HistogramBannerView::numberOfSubviews() const { - return 3; + return 6; } TextView * HistogramBannerView::textViewAtIndex(int i) const { - const TextView * textViews[3] = {&m_intervalView, &m_sizeView, &m_frequencyView}; + const TextView * textViews[6] = {&m_intervalLegendView, &m_intervalView, &m_sizeLegendView, &m_sizeView, &m_frequencyLegendView, &m_frequencyView}; return (TextView *)textViews[i]; } +PointerTextView * HistogramBannerView::pointerTextViewAtIndex(int index) const { + const PointerTextView * textViews[6] = {&m_intervalLegendView, nullptr, &m_sizeLegendView, nullptr, &m_frequencyLegendView, nullptr}; + return (PointerTextView *)textViews[index]; +} + } diff --git a/apps/statistics/histogram_banner_view.h b/apps/statistics/histogram_banner_view.h index 3a122c632..15b33dcfc 100644 --- a/apps/statistics/histogram_banner_view.h +++ b/apps/statistics/histogram_banner_view.h @@ -3,6 +3,7 @@ #include #include "../shared/banner_view.h" +#include "../i18n.h" namespace Statistics { @@ -12,8 +13,12 @@ public: private: int numberOfSubviews() const override; TextView * textViewAtIndex(int i) const override; + PointerTextView * pointerTextViewAtIndex(int index) const override; + PointerTextView m_intervalLegendView; BufferTextView m_intervalView; + PointerTextView m_sizeLegendView; BufferTextView m_sizeView; + PointerTextView m_frequencyLegendView; BufferTextView m_frequencyView; }; diff --git a/apps/statistics/histogram_controller.cpp b/apps/statistics/histogram_controller.cpp index 0ae47bdcd..09827866d 100644 --- a/apps/statistics/histogram_controller.cpp +++ b/apps/statistics/histogram_controller.cpp @@ -15,7 +15,7 @@ HistogramController::HistogramController(Responder * parentResponder, ButtonRowC ButtonRowDelegate(header, nullptr), m_bannerView(HistogramBannerView()), m_view(HistogramView(store, &m_bannerView)), - m_settingButton(Button(this, "Reglages de l'histogramme", Invocation([](void * context, void * sender) { + m_settingButton(Button(this, I18n::Message::HistogramSet, Invocation([](void * context, void * sender) { HistogramController * histogramController = (HistogramController *) context; StackViewController * stack = ((StackViewController *)histogramController->stackController()); stack->push(histogramController->histogramParameterController()); @@ -26,8 +26,8 @@ HistogramController::HistogramController(Responder * parentResponder, ButtonRowC { } -const char * HistogramController::title() const { - return "Histogramme"; +const char * HistogramController::title() { + return I18n::translate(I18n::Message::HistogramTab); } View * HistogramController::view() { @@ -115,8 +115,8 @@ bool HistogramController::isEmpty() const { return false; } -const char * HistogramController::emptyMessage() { - return "Aucune donnee a tracer"; +I18n::Message HistogramController::emptyMessage() { + return I18n::Message::NoDataToPlot; } Responder * HistogramController::defaultController() { @@ -145,7 +145,7 @@ Responder * HistogramController::tabController() const { void HistogramController::reloadBannerView() { char buffer[k_maxNumberOfCharacters+ Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)*2]; int numberOfChar = 0; - const char * legend = "Intervalle ["; + const char * legend = " ["; int legendLength = strlen(legend); strlcpy(buffer, legend, legendLength+1); numberOfChar += legendLength; @@ -158,10 +158,10 @@ void HistogramController::reloadBannerView() { legend = " "; legendLength = strlen(legend); strlcpy(buffer+numberOfChar, legend, legendLength+1); - m_bannerView.setLegendAtIndex(buffer, 0); + m_bannerView.setLegendAtIndex(buffer, 1); numberOfChar = 0; - legend = "Effectif: "; + legend = ": "; legendLength = strlen(legend); strlcpy(buffer, legend, legendLength+1); numberOfChar += legendLength; @@ -170,16 +170,16 @@ void HistogramController::reloadBannerView() { legend = " "; legendLength = strlen(legend); strlcpy(buffer+numberOfChar, legend, legendLength+1); - m_bannerView.setLegendAtIndex(buffer, 1); + m_bannerView.setLegendAtIndex(buffer, 3); numberOfChar = 0; - legend = "Frequence: "; + legend = ": "; legendLength = strlen(legend); strlcpy(buffer, legend, legendLength+1); numberOfChar += legendLength; float frequency = size/m_store->sumOfColumn(1); numberOfChar += Complex::convertFloatToText(frequency, buffer+legendLength, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); - m_bannerView.setLegendAtIndex(buffer, 2); + m_bannerView.setLegendAtIndex(buffer, 5); } bool HistogramController::moveSelection(int deltaIndex) { diff --git a/apps/statistics/histogram_controller.h b/apps/statistics/histogram_controller.h index 116484367..d00984bab 100644 --- a/apps/statistics/histogram_controller.h +++ b/apps/statistics/histogram_controller.h @@ -14,7 +14,7 @@ class HistogramController : public ViewController, public ButtonRowDelegate, pub public: HistogramController(Responder * parentResponder, ButtonRowController * header, Store * store); - const char * title() const override; + const char * title() override; View * view() override; StackViewController * stackController(); HistogramParameterController * histogramParameterController(); @@ -25,13 +25,13 @@ public: Button * buttonAtIndex(int index, ButtonRowController::Position position) const override; bool isEmpty() const override; - const char * emptyMessage() override; + I18n::Message emptyMessage() override; Responder * defaultController() override; void viewWillAppear() override; void willExitResponderChain(Responder * nextFirstResponder) override; private: constexpr static int k_maxNumberOfBarsPerWindow = 100; - constexpr static int k_maxNumberOfCharacters = 12; + constexpr static int k_maxNumberOfCharacters = 8; Responder * tabController() const; void reloadBannerView(); void initRangeParameters(); diff --git a/apps/statistics/histogram_parameter_controller.cpp b/apps/statistics/histogram_parameter_controller.cpp index feb6d46da..aac1aa903 100644 --- a/apps/statistics/histogram_parameter_controller.cpp +++ b/apps/statistics/histogram_parameter_controller.cpp @@ -7,14 +7,14 @@ using namespace Shared; namespace Statistics { HistogramParameterController::HistogramParameterController(Responder * parentResponder, Store * store) : - FloatParameterController(parentResponder, "Valider"), - m_cells{PointerTableCellWithEditableText(&m_selectableTableView, this, m_draftTextBuffer, nullptr), PointerTableCellWithEditableText(&m_selectableTableView, this, m_draftTextBuffer, nullptr)}, + FloatParameterController(parentResponder), + m_cells{PointerTableCellWithEditableText(&m_selectableTableView, this, m_draftTextBuffer, I18n::Message::Default), PointerTableCellWithEditableText(&m_selectableTableView, this, m_draftTextBuffer, I18n::Message::Default)}, m_store(store) { } -const char * HistogramParameterController::title() const { - return "Parametres de l'histogramme"; +const char * HistogramParameterController::title() { + return I18n::translate(I18n::Message::HistogramSet); } void HistogramParameterController::viewWillAppear() { @@ -33,8 +33,8 @@ void HistogramParameterController::willDisplayCellForIndex(HighlightCell * cell, return; } PointerTableCellWithEditableText * myCell = (PointerTableCellWithEditableText *)cell; - const char * labels[2] = {"Largeur des rectangles : ", "Debut de la serie : "}; - myCell->setText(labels[index]); + I18n::Message labels[2] = {I18n::Message::RectangleWidth, I18n::Message::BarStart}; + myCell->setMessage(labels[index]); FloatParameterController::willDisplayCellForIndex(cell, index); } @@ -54,7 +54,7 @@ void HistogramParameterController::setParameterAtIndex(int parameterIndex, float assert(parameterIndex >= 0 && parameterIndex < 2); if (parameterIndex == 0) { if (f <= 0.0f) { - app()->displayWarning("Valeur interdite"); + app()->displayWarning(I18n::Message::ForbiddenValue); return; } m_store->setBarWidth(f); diff --git a/apps/statistics/histogram_parameter_controller.h b/apps/statistics/histogram_parameter_controller.h index c0f770ddb..35cd24f27 100644 --- a/apps/statistics/histogram_parameter_controller.h +++ b/apps/statistics/histogram_parameter_controller.h @@ -10,7 +10,7 @@ namespace Statistics { class HistogramParameterController : public Shared::FloatParameterController { public: HistogramParameterController(Responder * parentResponder, Store * store); - const char * title() const override; + const char * title() override; void viewWillAppear() override; int numberOfRows() override; void willDisplayCellForIndex(HighlightCell * cell, int index) override; diff --git a/apps/statistics/store_controller.cpp b/apps/statistics/store_controller.cpp index 705681e81..ded96aa2f 100644 --- a/apps/statistics/store_controller.cpp +++ b/apps/statistics/store_controller.cpp @@ -21,10 +21,10 @@ void StoreController::willDisplayCellAtLocation(HighlightCell * cell, int i, int } EvenOddPointerTextCell * mytitleCell = (EvenOddPointerTextCell *)cell; if (i == 0) { - mytitleCell->setText("Valeurs"); + mytitleCell->setMessage(I18n::Message::Values); return; } - mytitleCell->setText("Effectifs"); + mytitleCell->setMessage(I18n::Message::Sizes); } HighlightCell * StoreController::titleCells(int index) { diff --git a/apps/title_bar_view.cpp b/apps/title_bar_view.cpp index 927985a97..802aa4a74 100644 --- a/apps/title_bar_view.cpp +++ b/apps/title_bar_view.cpp @@ -8,7 +8,7 @@ using namespace Poincare; TitleBarView::TitleBarView() : View(), - m_titleView(KDText::FontSize::Small, nullptr, 0.5f, 0.5f, KDColorWhite, Palette::YellowDark), + m_titleView(KDText::FontSize::Small, I18n::Message::Default, 0.5f, 0.5f, KDColorWhite, Palette::YellowDark), m_preferenceView(KDText::FontSize::Small, 1.0f, 0.5, KDColorWhite, Palette::YellowDark) { } @@ -18,8 +18,8 @@ void TitleBarView::drawRect(KDContext * ctx, KDRect rect) const { } -void TitleBarView::setTitle(const char * title) { - m_titleView.setText(title); +void TitleBarView::setTitle(I18n::Message title) { + m_titleView.setMessage(title); } void TitleBarView::setChargeState(Ion::Battery::Charge chargeState) { diff --git a/apps/title_bar_view.h b/apps/title_bar_view.h index 962caa2af..52777987e 100644 --- a/apps/title_bar_view.h +++ b/apps/title_bar_view.h @@ -3,12 +3,13 @@ #include #include "battery_view.h" +#include "i18n.h" class TitleBarView : public View { public: TitleBarView(); void drawRect(KDContext * ctx, KDRect rect) const override; - void setTitle(const char * title); + void setTitle(I18n::Message title); void setChargeState(Ion::Battery::Charge chargeState); void refreshPreferences(); private: diff --git a/apps/toolbox_node.cpp b/apps/toolbox_node.cpp index 919c8553c..6345f5e91 100644 --- a/apps/toolbox_node.cpp +++ b/apps/toolbox_node.cpp @@ -1,6 +1,6 @@ #include "toolbox_node.h" -const char * ToolboxNode::text() const { +I18n::Message ToolboxNode::text() const { return m_text; } diff --git a/apps/toolbox_node.h b/apps/toolbox_node.h index 82c8f900d..2b5554eac 100644 --- a/apps/toolbox_node.h +++ b/apps/toolbox_node.h @@ -5,17 +5,17 @@ class ToolboxNode : public Node { public: - constexpr ToolboxNode(const char * label = nullptr, const char * text = nullptr, const ToolboxNode * children = nullptr, int numberOfChildren = 0) : + constexpr ToolboxNode(I18n::Message label = I18n::Message::Default, I18n::Message text = I18n::Message::Default, const ToolboxNode * children = nullptr, int numberOfChildren = 0) : Node(label, numberOfChildren), m_children(children), m_text(text) { }; const Node * children(int index) const override; - const char * text() const; + I18n::Message text() const; private: const ToolboxNode * m_children; - const char * m_text; + I18n::Message m_text; }; #endif diff --git a/apps/variable_box_controller.cpp b/apps/variable_box_controller.cpp index 31192755c..6225315be 100644 --- a/apps/variable_box_controller.cpp +++ b/apps/variable_box_controller.cpp @@ -16,8 +16,8 @@ VariableBoxController::ContentViewController::ContentViewController(Responder * { } -const char * VariableBoxController::ContentViewController::title() const { - return "Variable"; +const char * VariableBoxController::ContentViewController::title() { + return I18n::translate(I18n::Message::Variables); } View * VariableBoxController::ContentViewController::view() { @@ -106,9 +106,9 @@ int VariableBoxController::ContentViewController::reusableCellCount(int type) { void VariableBoxController::ContentViewController::willDisplayCellForIndex(HighlightCell * cell, int index) { if (m_currentPage == Page::RootMenu) { - const char * label = nodeLabelAtIndex(index); + I18n::Message label = nodeLabelAtIndex(index); PointerTableCell * myCell = (PointerTableCell *)cell; - myCell->setText(label); + myCell->setMessage(label); return; } VariableBoxLeafCell * myCell = (VariableBoxLeafCell *)cell; @@ -213,9 +213,9 @@ void VariableBoxController::ContentViewController::putLabelAtIndexInBuffer(int i } } -const char * VariableBoxController::ContentViewController::nodeLabelAtIndex(int index) { +I18n::Message VariableBoxController::ContentViewController::nodeLabelAtIndex(int index) { assert(m_currentPage == Page::RootMenu); - const char * labels[3] = {"Nombre", "Liste", "Matrice"}; + I18n::Message labels[3] = {I18n::Message::Number, I18n::Message::List, I18n::Message::Matrix}; return labels[index]; } diff --git a/apps/variable_box_controller.h b/apps/variable_box_controller.h index cf8c5e8da..c2c76f54b 100644 --- a/apps/variable_box_controller.h +++ b/apps/variable_box_controller.h @@ -4,6 +4,7 @@ #include #include #include "variable_box_leaf_cell.h" +#include "i18n.h" class VariableBoxController : public StackViewController { public: @@ -17,7 +18,7 @@ private: public: ContentViewController(Responder * parentResponder, Poincare::Context * context); View * view() override; - const char * title() const override; + const char * title() override; void didBecomeFirstResponder() override; bool handleEvent(Ion::Events::Event event) override; int numberOfRows() override; @@ -45,7 +46,7 @@ private: constexpr static KDCoordinate k_nodeRowHeight = 40; Page pageAtIndex(int index); void putLabelAtIndexInBuffer(int index, char * buffer); - const char * nodeLabelAtIndex(int index); + I18n::Message nodeLabelAtIndex(int index); const Poincare::Expression * expressionForIndex(int index); Poincare::Context * m_context; diff --git a/escher/include/escher.h b/escher/include/escher.h index 5d1b2544d..9a4812f83 100644 --- a/escher/include/escher.h +++ b/escher/include/escher.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include diff --git a/escher/include/escher/alternate_empty_view_controller.h b/escher/include/escher/alternate_empty_view_controller.h index aa86fc46f..8cef1b8a3 100644 --- a/escher/include/escher/alternate_empty_view_controller.h +++ b/escher/include/escher/alternate_empty_view_controller.h @@ -2,6 +2,7 @@ #define ESCHER_ALTERNATE_EMPTY_VIEW_H #include +#include #include #include @@ -9,7 +10,7 @@ class AlternateEmptyViewController : public ViewController { public: AlternateEmptyViewController(Responder * parentResponder, ViewController * mainViewController, AlternateEmptyViewDelegate * delegate); View * view() override; - const char * title() const override; + const char * title() override; bool handleEvent(Ion::Events::Event event) override; void didBecomeFirstResponder() override; void viewWillAppear() override; diff --git a/escher/include/escher/alternate_empty_view_delegate.h b/escher/include/escher/alternate_empty_view_delegate.h index 97a9dc9a6..19a7a1ca9 100644 --- a/escher/include/escher/alternate_empty_view_delegate.h +++ b/escher/include/escher/alternate_empty_view_delegate.h @@ -2,13 +2,14 @@ #define ESCHER_ALTERNATE_EMPTY_VIEW_DELEGATE_H #include +#include class AlternateEmptyViewController; class AlternateEmptyViewDelegate { public: virtual bool isEmpty() const = 0; - virtual const char * emptyMessage() = 0; + virtual I18n::Message emptyMessage() = 0; virtual Responder * defaultController() = 0; }; diff --git a/escher/include/escher/app.h b/escher/include/escher/app.h index 8cedff40f..b5b5c3544 100644 --- a/escher/include/escher/app.h +++ b/escher/include/escher/app.h @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -21,17 +22,17 @@ class Container; class App : public Responder { public: constexpr static uint8_t Magic = 0xA8; - App(Container * container, ViewController * rootViewController, const char * name = nullptr, const char * upperName = nullptr, const Image * icon = nullptr); + App(Container * container, ViewController * rootViewController, I18n::Message name = (I18n::Message)0, I18n::Message upperName = (I18n::Message)0, const Image * icon = nullptr, I18n::Message warningMessage = (I18n::Message)0); void setFirstResponder(Responder * responder); Responder * firstResponder(); bool processEvent(Ion::Events::Event event); void displayModalViewController(ViewController * vc, float verticalAlignment, float horizontalAlignment, KDCoordinate topMargin = 0, KDCoordinate leftMargin = 0, KDCoordinate bottomMargin = 0, KDCoordinate rightMargin = 0); void dismissModalViewController(); - void displayWarning(const char * warningMessage); + void displayWarning(I18n::Message warningMessage); const Container * container() const; - const char * name(); - const char * upperName(); + I18n::Message name(); + I18n::Message upperName(); const Image * icon(); uint8_t m_magic; // Poor man's RTTI @@ -45,8 +46,8 @@ private: Container * m_container; Responder * m_firstResponder; WarningController m_warningController; - const char * m_name; - const char * m_upperName; + I18n::Message m_name; + I18n::Message m_upperName; const Image * m_icon; }; diff --git a/escher/include/escher/button.h b/escher/include/escher/button.h index 656fe5ac1..f361110e1 100644 --- a/escher/include/escher/button.h +++ b/escher/include/escher/button.h @@ -2,13 +2,14 @@ #define ESCHER_BUTTON_H #include +#include #include #include #include class Button : public HighlightCell, public Responder { public: - Button(Responder * parentResponder, const char * textBody, Invocation invocation, KDText::FontSize size = KDText::FontSize::Small, KDColor textColor = KDColorBlack); + Button(Responder * parentResponder, I18n::Message textBody, Invocation invocation, KDText::FontSize size = KDText::FontSize::Small, KDColor textColor = KDColorBlack); bool handleEvent(Ion::Events::Event event) override; void setHighlighted(bool highlight) override; KDSize minimalSizeForOptimalDisplay() const override; diff --git a/escher/include/escher/button_row_controller.h b/escher/include/escher/button_row_controller.h index 2e1788b4d..c9f833614 100644 --- a/escher/include/escher/button_row_controller.h +++ b/escher/include/escher/button_row_controller.h @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -21,7 +22,7 @@ public: }; ButtonRowController(Responder * parentResponder, ViewController * mainViewController, ButtonRowDelegate * delegate, Position position = Position::Top, Style = Style::PlainWhite); View * view() override; - const char * title() const override; + const char * title() override; void didBecomeFirstResponder() override; bool handleEvent(Ion::Events::Event event) override; bool setSelectedButton(int selectedButton); diff --git a/escher/include/escher/even_odd_pointer_text_cell.h b/escher/include/escher/even_odd_pointer_text_cell.h index 067c6a097..4b44b2d61 100644 --- a/escher/include/escher/even_odd_pointer_text_cell.h +++ b/escher/include/escher/even_odd_pointer_text_cell.h @@ -2,6 +2,7 @@ #define ESCHER_EVEN_ODD_POINTER_TEXT_CELL_H #include +#include #include class EvenOddPointerTextCell : public EvenOddCell { @@ -9,7 +10,7 @@ public: EvenOddPointerTextCell(KDText::FontSize size = KDText::FontSize::Large); void setEven(bool even) override; void setHighlighted(bool highlight) override; - void setText(const char * textContent, KDColor textColor = KDColorBlack); + void setMessage(I18n::Message textContent, KDColor textColor = KDColorBlack); void setAlignment(float horizontalAlignment, float verticalAlignment); int numberOfSubviews() const override; View * subviewAtIndex(int index) override; diff --git a/escher/include/escher/expression_table_cell_with_pointer.h b/escher/include/escher/expression_table_cell_with_pointer.h index bfc13fcfa..8cbf2b519 100644 --- a/escher/include/escher/expression_table_cell_with_pointer.h +++ b/escher/include/escher/expression_table_cell_with_pointer.h @@ -2,14 +2,15 @@ #define ESCHER_EXPRESSION_TABLE_CELL_WITH_POINTER_H #include +#include #include class ExpressionTableCellWithPointer : public ExpressionTableCell { public: - ExpressionTableCellWithPointer(char * accessoryText = nullptr, Layout layout = Layout::Horizontal); + ExpressionTableCellWithPointer(I18n::Message accessoryMessage = (I18n::Message)0, Layout layout = Layout::Horizontal); View * accessoryView() const override; void setHighlighted(bool highlight) override; - void setAccessoryText(const char * textBody); + void setAccessoryMessage(I18n::Message messageBody); private: PointerTextView m_accessoryView; }; diff --git a/escher/include/escher/i18n.h b/escher/include/escher/i18n.h new file mode 100644 index 000000000..5002a72a6 --- /dev/null +++ b/escher/include/escher/i18n.h @@ -0,0 +1,13 @@ +#ifndef ESCHER_I18N_H +#define ESCHER_I18N_H + +#include + +namespace I18n { + enum class Message : uint16_t; + enum class Language : uint16_t; + const char * translate(Message m, Language l = (Language)0); +} + +#endif + diff --git a/escher/include/escher/input_view_controller.h b/escher/include/escher/input_view_controller.h index 6bb0e9fc1..4f69ab74d 100644 --- a/escher/include/escher/input_view_controller.h +++ b/escher/include/escher/input_view_controller.h @@ -9,7 +9,6 @@ class InputViewController : public ModalViewController, TextFieldDelegate { public: InputViewController(Responder * parentResponder, ViewController * child, TextFieldDelegate * textFieldDelegate); - const char * title() const override; void edit(Responder * caller, Ion::Events::Event event, void * context, const char * initialText, Invocation::Action successAction, Invocation::Action failureAction); const char * textBody(); void setTextFieldDelegate(TextFieldDelegate * textFieldDelegate); diff --git a/escher/include/escher/menu_view.h b/escher/include/escher/menu_view.h deleted file mode 100644 index 693bfbce0..000000000 --- a/escher/include/escher/menu_view.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef ESCHER_MENU_VIEW_H -#define ESCHER_MENU_VIEW_H - -#include - -class MenuView : public View { -public: - MenuView(Menu * menu); - //void drawRect(KDRect rect) override; -//private: - //KDColor m_color; -}; - -#endif diff --git a/escher/include/escher/modal_view_controller.h b/escher/include/escher/modal_view_controller.h index 8414a0419..f4d2e0e1d 100644 --- a/escher/include/escher/modal_view_controller.h +++ b/escher/include/escher/modal_view_controller.h @@ -8,7 +8,6 @@ class ModalViewController : public ViewController { public: ModalViewController(Responder * parentResponder, ViewController * child); View * view() override; - const char * title() const override; bool handleEvent(Ion::Events::Event event) override; void didBecomeFirstResponder() override; diff --git a/escher/include/escher/pointer_table_cell.h b/escher/include/escher/pointer_table_cell.h index 4691efdea..7bf8e875f 100644 --- a/escher/include/escher/pointer_table_cell.h +++ b/escher/include/escher/pointer_table_cell.h @@ -2,14 +2,15 @@ #define ESCHER_POINTER_TABLE_CELL_H #include +#include #include class PointerTableCell : public TableCell { public: - PointerTableCell(char * label = nullptr, KDText::FontSize size = KDText::FontSize::Small, Layout layout = Layout::Horizontal); + PointerTableCell(I18n::Message label = (I18n::Message)0, KDText::FontSize size = KDText::FontSize::Small, Layout layout = Layout::Horizontal); View * labelView() const override; virtual void setHighlighted(bool highlight) override; - void setText(const char * text); + void setMessage(I18n::Message message); virtual void setTextColor(KDColor color); private: PointerTextView m_pointerTextView; diff --git a/escher/include/escher/pointer_table_cell_with_buffer.h b/escher/include/escher/pointer_table_cell_with_buffer.h index fdf5e4b91..41a0673ee 100644 --- a/escher/include/escher/pointer_table_cell_with_buffer.h +++ b/escher/include/escher/pointer_table_cell_with_buffer.h @@ -6,7 +6,7 @@ class PointerTableCellWithBuffer : public PointerTableCell { public: - PointerTableCellWithBuffer(char * label = nullptr); + PointerTableCellWithBuffer(I18n::Message message = (I18n::Message)0); View * accessoryView() const override; void setHighlighted(bool highlight) override; void setAccessoryText(const char * textBody); diff --git a/escher/include/escher/pointer_table_cell_with_chevron.h b/escher/include/escher/pointer_table_cell_with_chevron.h index 875de7979..c1743dec2 100644 --- a/escher/include/escher/pointer_table_cell_with_chevron.h +++ b/escher/include/escher/pointer_table_cell_with_chevron.h @@ -6,7 +6,7 @@ class PointerTableCellWithChevron : public PointerTableCell { public: - PointerTableCellWithChevron(char * label = nullptr, KDText::FontSize size = KDText::FontSize::Small); + PointerTableCellWithChevron(I18n::Message message = (I18n::Message)0, KDText::FontSize size = KDText::FontSize::Small); View * accessoryView() const override; private: ChevronView m_accessoryView; diff --git a/escher/include/escher/pointer_table_cell_with_chevron_and_expression.h b/escher/include/escher/pointer_table_cell_with_chevron_and_expression.h index f5672c8df..30c2e7903 100644 --- a/escher/include/escher/pointer_table_cell_with_chevron_and_expression.h +++ b/escher/include/escher/pointer_table_cell_with_chevron_and_expression.h @@ -6,7 +6,7 @@ class PointerTableCellWithChevronAndExpression : public PointerTableCellWithChevron { public: - PointerTableCellWithChevronAndExpression(char * label = nullptr, KDText::FontSize size = KDText::FontSize::Small); + PointerTableCellWithChevronAndExpression(I18n::Message message = (I18n::Message)0, KDText::FontSize size = KDText::FontSize::Small); View * subAccessoryView() const override; void setHighlighted(bool highlight) override; void setExpression(Poincare::ExpressionLayout * expressionLayout); diff --git a/escher/include/escher/pointer_table_cell_with_chevron_and_pointer.h b/escher/include/escher/pointer_table_cell_with_chevron_and_pointer.h index 695107b79..f11e31630 100644 --- a/escher/include/escher/pointer_table_cell_with_chevron_and_pointer.h +++ b/escher/include/escher/pointer_table_cell_with_chevron_and_pointer.h @@ -8,7 +8,7 @@ public: PointerTableCellWithChevronAndPointer(KDText::FontSize labelSize = KDText::FontSize::Small, KDText::FontSize contentSize = KDText::FontSize::Small); View * subAccessoryView() const override; void setHighlighted(bool highlight) override; - void setSubtitle(const char * text); + void setSubtitle(I18n::Message text); private: PointerTextView m_subtitleView; }; diff --git a/escher/include/escher/pointer_table_cell_with_editable_text.h b/escher/include/escher/pointer_table_cell_with_editable_text.h index 0cf8b4495..16a7886f5 100644 --- a/escher/include/escher/pointer_table_cell_with_editable_text.h +++ b/escher/include/escher/pointer_table_cell_with_editable_text.h @@ -7,7 +7,7 @@ class PointerTableCellWithEditableText : public Responder, public PointerTableCell { public: - PointerTableCellWithEditableText(Responder * parentResponder, TextFieldDelegate * textFieldDelegate, char * draftTextBuffer, char * label = nullptr); + PointerTableCellWithEditableText(Responder * parentResponder, TextFieldDelegate * textFieldDelegate, char * draftTextBuffer, I18n::Message message = (I18n::Message)0); View * accessoryView() const override; const char * editedText() const; void didBecomeFirstResponder() override; diff --git a/escher/include/escher/pointer_table_cell_with_pointer.h b/escher/include/escher/pointer_table_cell_with_pointer.h index 91113101d..9a0b54477 100644 --- a/escher/include/escher/pointer_table_cell_with_pointer.h +++ b/escher/include/escher/pointer_table_cell_with_pointer.h @@ -5,11 +5,10 @@ class PointerTableCellWithPointer : public PointerTableCell { public: - PointerTableCellWithPointer(char * label = nullptr, Layout layout = Layout::Vertical); + PointerTableCellWithPointer(I18n::Message message = (I18n::Message)0, Layout layout = Layout::Vertical); View * accessoryView() const override; void setHighlighted(bool highlight) override; - void setAccessoryText(const char * textBody); - const char * accessoryText(); + void setAccessoryMessage(I18n::Message textBody); void setTextColor(KDColor color) override; void setAccessoryTextColor(KDColor color); protected: diff --git a/escher/include/escher/pointer_table_cell_with_switch.h b/escher/include/escher/pointer_table_cell_with_switch.h index 339d0c6f8..7b0b76d2a 100644 --- a/escher/include/escher/pointer_table_cell_with_switch.h +++ b/escher/include/escher/pointer_table_cell_with_switch.h @@ -6,7 +6,7 @@ class PointerTableCellWithSwitch : public PointerTableCell { public: - PointerTableCellWithSwitch(char * label = nullptr); + PointerTableCellWithSwitch(I18n::Message message = (I18n::Message)0); View * accessoryView() const override; private: SwitchView m_accessoryView; diff --git a/escher/include/escher/pointer_text_view.h b/escher/include/escher/pointer_text_view.h index ec0a709ef..4b3af6f6f 100644 --- a/escher/include/escher/pointer_text_view.h +++ b/escher/include/escher/pointer_text_view.h @@ -2,15 +2,17 @@ #define ESCHER_POINTER_TEXT_VIEW_H #include +#include class PointerTextView : public TextView { public: - PointerTextView(KDText::FontSize size = KDText::FontSize::Large, const char * text = nullptr, float horizontalAlignment = 0.0f, float verticalAlignment = 0.0f, + PointerTextView(KDText::FontSize size = KDText::FontSize::Large, I18n::Message message = (I18n::Message)0, float horizontalAlignment = 0.0f, float verticalAlignment = 0.0f, KDColor textColor = KDColorBlack, KDColor backgroundColor = KDColorWhite); void setText(const char * text) override; + void setMessage(I18n::Message message); const char * text() const override; private: - const char * m_textPointer; + I18n::Message m_message; }; -#endif \ No newline at end of file +#endif diff --git a/escher/include/escher/stack_view.h b/escher/include/escher/stack_view.h index f13951a91..ec3a5d649 100644 --- a/escher/include/escher/stack_view.h +++ b/escher/include/escher/stack_view.h @@ -2,13 +2,13 @@ #define ESCHER_STACK_VIEW_H #include -#include +#include class StackView : public View { public: StackView(); void drawRect(KDContext * ctx, KDRect rect) const override; - void setName(const char * name); + void setNamedController(ViewController * controller); void setTextColor(KDColor textColor); void setBackgroundColor(KDColor backgroundColor); void setSeparatorColor(KDColor separatorColor); @@ -18,12 +18,10 @@ protected: void logAttributes(std::ostream &os) const override; #endif private: + KDColor m_textColor; KDColor m_backgroundColor; KDColor m_separatorColor; - int numberOfSubviews() const override; - View * subviewAtIndex(int index) override; - void layoutSubviews() override; - PointerTextView m_textView; + ViewController * m_controller; }; #endif diff --git a/escher/include/escher/stack_view_controller.h b/escher/include/escher/stack_view_controller.h index 06e197284..dcb05f7e6 100644 --- a/escher/include/escher/stack_view_controller.h +++ b/escher/include/escher/stack_view_controller.h @@ -18,7 +18,7 @@ public: View * view() override; - const char * title() const override; + const char * title() override; bool handleEvent(Ion::Events::Event event) override; void didBecomeFirstResponder() override; void viewWillAppear() override; @@ -28,7 +28,7 @@ private: public: ControllerView(bool displayFirstStackHeader); void setContentView(View * view); - void pushStack(const char * name, KDColor textColor, KDColor backgroundColor, KDColor separatorColor); + void pushStack(ViewController * controller, KDColor textColor, KDColor backgroundColor, KDColor separatorColor); void popStack(); protected: #if ESCHER_VIEW_LOGGING diff --git a/escher/include/escher/tab_view.h b/escher/include/escher/tab_view.h index 5f63103a5..ab662d356 100644 --- a/escher/include/escher/tab_view.h +++ b/escher/include/escher/tab_view.h @@ -2,7 +2,9 @@ #define ESCHER_TAB_VIEW_H #include +#include #include +#include class TabViewController; @@ -12,7 +14,7 @@ public: int numberOfTabs() const; void drawRect(KDContext * ctx, KDRect rect) const override; - void addTabNamed(const char * name); + void addTab(ViewController * controller); //TODO: void removeLastTab(); void setActiveIndex(int index); void setSelectedIndex(int index); diff --git a/escher/include/escher/tab_view_cell.h b/escher/include/escher/tab_view_cell.h index 078f24787..4ed0f3e05 100644 --- a/escher/include/escher/tab_view_cell.h +++ b/escher/include/escher/tab_view_cell.h @@ -2,13 +2,15 @@ #define ESCHER_TAB_VIEW_CELL_H #include +#include #include +#include class TabViewCell : public View { public: TabViewCell(); void drawRect(KDContext * ctx, KDRect rect) const override; - void setName(const char * name); + void setNamedController(ViewController * controller); void setActive(bool active); void setSelected(bool selected); KDSize minimalSizeForOptimalDisplay() const override; @@ -20,7 +22,7 @@ protected: private: bool m_active; bool m_selected; - const char * m_name; + ViewController * m_controller; }; #endif diff --git a/escher/include/escher/table_cell.h b/escher/include/escher/table_cell.h index b14f59dcb..00fc79794 100644 --- a/escher/include/escher/table_cell.h +++ b/escher/include/escher/table_cell.h @@ -6,8 +6,8 @@ class TableCell : public HighlightCell { public: enum class Layout { - Vertical, - Horizontal + Vertical, + Horizontal }; TableCell(Layout layout = Layout::Horizontal); virtual View * labelView() const; diff --git a/escher/include/escher/view_controller.h b/escher/include/escher/view_controller.h index 6c8f2e7c8..c136c5707 100644 --- a/escher/include/escher/view_controller.h +++ b/escher/include/escher/view_controller.h @@ -2,6 +2,7 @@ #define ESCHER_VIEW_CONTROLLER_H #include +#include extern "C" { #include } @@ -29,7 +30,7 @@ extern "C" { class ViewController : public Responder { public: ViewController(Responder * parentResponder); - virtual const char * title() const; + virtual const char * title(); virtual View * view() = 0; virtual void viewWillAppear(); virtual void viewWillDisappear(); diff --git a/escher/include/escher/warning_controller.h b/escher/include/escher/warning_controller.h index 3a459dfd8..85d032560 100644 --- a/escher/include/escher/warning_controller.h +++ b/escher/include/escher/warning_controller.h @@ -4,19 +4,20 @@ #include #include #include +#include class WarningController : public ViewController { public: - WarningController(Responder * parentResponder); - void setLabel(const char *); - const char * title() const override; + WarningController(Responder * parentResponder, I18n::Message warningMessage); + void setLabel(I18n::Message message); + const char * title() override; View * view() override; bool handleEvent(Ion::Events::Event event) override; private: class ContentView : public SolidColorView { public: ContentView(); - void setLabel(const char *); + void setLabel(I18n::Message message); int numberOfSubviews() const override; View * subviewAtIndex(int index) override; void layoutSubviews() override; @@ -28,6 +29,7 @@ private: }; ContentView m_contentView; + I18n::Message m_warningMessage; }; #endif diff --git a/escher/src/alternate_empty_view_controller.cpp b/escher/src/alternate_empty_view_controller.cpp index 551ee77cb..5b1a66ddd 100644 --- a/escher/src/alternate_empty_view_controller.cpp +++ b/escher/src/alternate_empty_view_controller.cpp @@ -6,7 +6,7 @@ /* ContentView */ AlternateEmptyViewController::ContentView::ContentView(ViewController * mainViewController, AlternateEmptyViewDelegate * delegate) : - m_message(PointerTextView(KDText::FontSize::Small, nullptr, 0.5f, 0.5f, KDColorBlack, Palette::WallScreen)), + m_message(PointerTextView(KDText::FontSize::Small, (I18n::Message)0, 0.5f, 0.5f, KDColorBlack, Palette::WallScreen)), m_mainViewController(mainViewController), m_delegate(delegate) { @@ -19,7 +19,7 @@ int AlternateEmptyViewController::ContentView::numberOfSubviews() const { View * AlternateEmptyViewController::ContentView::subviewAtIndex(int index) { assert(index == 0); if (m_delegate->isEmpty()) { - m_message.setText(m_delegate->emptyMessage()); + m_message.setMessage(m_delegate->emptyMessage()); return &m_message; } return m_mainViewController->view(); @@ -53,7 +53,7 @@ View * AlternateEmptyViewController::view() { return &m_contentView; } -const char * AlternateEmptyViewController::title() const { +const char * AlternateEmptyViewController::title() { return m_contentView.mainViewController()->title(); } diff --git a/escher/src/app.cpp b/escher/src/app.cpp index 603823a29..227beb247 100644 --- a/escher/src/app.cpp +++ b/escher/src/app.cpp @@ -4,13 +4,13 @@ extern "C" { #include } -App::App(Container * container, ViewController * rootViewController, const char * name, const char * upperName, const Image * icon) : +App::App(Container * container, ViewController * rootViewController, I18n::Message name, I18n::Message upperName, const Image * icon, I18n::Message warningMessage) : Responder(nullptr), m_magic(Magic), m_modalViewController(ModalViewController(this, rootViewController)), m_container(container), m_firstResponder(nullptr), - m_warningController(WarningController(this)), + m_warningController(WarningController(this, warningMessage)), m_name(name), m_upperName(upperName), m_icon(icon) @@ -57,11 +57,11 @@ void App::setFirstResponder(Responder * responder) { } } -const char * App::name() { +I18n::Message App::name() { return m_name; } -const char * App::upperName() { +I18n::Message App::upperName() { return m_upperName; } @@ -78,7 +78,7 @@ void App::dismissModalViewController() { m_modalViewController.dismissModalViewController(); } -void App::displayWarning(const char * warningMessage) { +void App::displayWarning(I18n::Message warningMessage) { m_warningController.setLabel(warningMessage); m_modalViewController.displayModalViewController(&m_warningController, 0.5f, 0.5f); } diff --git a/escher/src/button.cpp b/escher/src/button.cpp index 8c9c8a28f..c97ebc769 100644 --- a/escher/src/button.cpp +++ b/escher/src/button.cpp @@ -2,7 +2,7 @@ #include #include -Button::Button(Responder * parentResponder, const char * textBody, Invocation invocation, KDText::FontSize size, KDColor textColor) : +Button::Button(Responder * parentResponder, I18n::Message textBody, Invocation invocation, KDText::FontSize size, KDColor textColor) : HighlightCell(), Responder(parentResponder), m_pointerTextView(PointerTextView(size, textBody, 0.5f, 0.5f, textColor)), diff --git a/escher/src/button_row_controller.cpp b/escher/src/button_row_controller.cpp index 03436d511..c7212b850 100644 --- a/escher/src/button_row_controller.cpp +++ b/escher/src/button_row_controller.cpp @@ -182,7 +182,7 @@ View * ButtonRowController::view() { return &m_contentView; } -const char * ButtonRowController::title() const { +const char * ButtonRowController::title() { return m_contentView.mainViewController()->title(); } diff --git a/escher/src/even_odd_pointer_text_cell.cpp b/escher/src/even_odd_pointer_text_cell.cpp index 3a9bab8cf..9f0cffa34 100644 --- a/escher/src/even_odd_pointer_text_cell.cpp +++ b/escher/src/even_odd_pointer_text_cell.cpp @@ -3,7 +3,7 @@ EvenOddPointerTextCell::EvenOddPointerTextCell(KDText::FontSize size) : EvenOddCell(), - m_pointerTextView(size, nullptr, 0.5f, 0.5f) + m_pointerTextView(size, (I18n::Message)0, 0.5f, 0.5f) { } @@ -17,8 +17,8 @@ void EvenOddPointerTextCell::setEven(bool even) { m_pointerTextView.setBackgroundColor(backgroundColor()); } -void EvenOddPointerTextCell::setText(const char * title, KDColor textColor) { - m_pointerTextView.setText(title); +void EvenOddPointerTextCell::setMessage(I18n::Message title, KDColor textColor) { + m_pointerTextView.setMessage(title); m_pointerTextView.setTextColor(textColor); } diff --git a/escher/src/expression_table_cell_with_pointer.cpp b/escher/src/expression_table_cell_with_pointer.cpp index 623fde4f2..dde44a0c0 100644 --- a/escher/src/expression_table_cell_with_pointer.cpp +++ b/escher/src/expression_table_cell_with_pointer.cpp @@ -2,9 +2,9 @@ #include #include -ExpressionTableCellWithPointer::ExpressionTableCellWithPointer(char * accessoryText, Layout layout) : +ExpressionTableCellWithPointer::ExpressionTableCellWithPointer(I18n::Message accessoryMessage, Layout layout) : ExpressionTableCell(layout), - m_accessoryView(PointerTextView(KDText::FontSize::Small, accessoryText, 0.0f, 0.5f, Palette::GreyDark, KDColorWhite)) + m_accessoryView(PointerTextView(KDText::FontSize::Small, accessoryMessage, 0.0f, 0.5f, Palette::GreyDark, KDColorWhite)) { if (layout == Layout::Horizontal) { m_accessoryView.setAlignment(1.0f, 0.5f); @@ -21,6 +21,6 @@ void ExpressionTableCellWithPointer::setHighlighted(bool highlight) { m_accessoryView.setBackgroundColor(backgroundColor); } -void ExpressionTableCellWithPointer::setAccessoryText(const char * text) { - m_accessoryView.setText(text); +void ExpressionTableCellWithPointer::setAccessoryMessage(I18n::Message text) { + m_accessoryView.setMessage(text); } diff --git a/escher/src/input_view_controller.cpp b/escher/src/input_view_controller.cpp index 3483da950..620656278 100644 --- a/escher/src/input_view_controller.cpp +++ b/escher/src/input_view_controller.cpp @@ -30,10 +30,6 @@ InputViewController::InputViewController(Responder * parentResponder, ViewContro { } -const char * InputViewController::title() const { - return "InputViewController"; -} - const char * InputViewController::textBody() { return m_textFieldController.textField()->text(); } diff --git a/escher/src/modal_view_controller.cpp b/escher/src/modal_view_controller.cpp index 5ce6409b5..486a51f3d 100644 --- a/escher/src/modal_view_controller.cpp +++ b/escher/src/modal_view_controller.cpp @@ -106,10 +106,6 @@ bool ModalViewController::isDisplayingModal() { return m_contentView.isDisplayingModal(); } -const char * ModalViewController::title() const { - return "Modal View Controller"; -} - void ModalViewController::displayModalViewController(ViewController * vc, float verticalAlignment, float horizontalAlignment, KDCoordinate topMargin, KDCoordinate leftMargin, KDCoordinate bottomMargin, KDCoordinate rightMargin) { m_currentModalViewController = vc; diff --git a/escher/src/pointer_table_cell.cpp b/escher/src/pointer_table_cell.cpp index a4b92e81e..bece85eb0 100644 --- a/escher/src/pointer_table_cell.cpp +++ b/escher/src/pointer_table_cell.cpp @@ -2,7 +2,7 @@ #include #include -PointerTableCell::PointerTableCell(char * label, KDText::FontSize size, Layout layout) : +PointerTableCell::PointerTableCell(I18n::Message label, KDText::FontSize size, Layout layout) : TableCell(layout), m_pointerTextView(PointerTextView(size, label, 0, 0.5, KDColorBlack, KDColorWhite)) { @@ -18,8 +18,8 @@ void PointerTableCell::setHighlighted(bool highlight) { m_pointerTextView.setBackgroundColor(backgroundColor); } -void PointerTableCell::setText(const char * text) { - m_pointerTextView.setText(text); +void PointerTableCell::setMessage(I18n::Message text) { + m_pointerTextView.setMessage(text); layoutSubviews(); } diff --git a/escher/src/pointer_table_cell_with_buffer.cpp b/escher/src/pointer_table_cell_with_buffer.cpp index 4c933e0d8..0deadee34 100644 --- a/escher/src/pointer_table_cell_with_buffer.cpp +++ b/escher/src/pointer_table_cell_with_buffer.cpp @@ -1,8 +1,8 @@ #include #include -PointerTableCellWithBuffer::PointerTableCellWithBuffer(char * label) : - PointerTableCell(label), +PointerTableCellWithBuffer::PointerTableCellWithBuffer(I18n::Message message) : + PointerTableCell(message), m_accessoryView(BufferTextView(KDText::FontSize::Large, 1.0f, 0.5f)) { } diff --git a/escher/src/pointer_table_cell_with_chevron.cpp b/escher/src/pointer_table_cell_with_chevron.cpp index f1d6c653a..da0c3e8d7 100644 --- a/escher/src/pointer_table_cell_with_chevron.cpp +++ b/escher/src/pointer_table_cell_with_chevron.cpp @@ -1,7 +1,7 @@ #include -PointerTableCellWithChevron::PointerTableCellWithChevron(char * label, KDText::FontSize size) : - PointerTableCell(label, size), +PointerTableCellWithChevron::PointerTableCellWithChevron(I18n::Message message, KDText::FontSize size) : + PointerTableCell(message, size), m_accessoryView(ChevronView()) { } diff --git a/escher/src/pointer_table_cell_with_chevron_and_expression.cpp b/escher/src/pointer_table_cell_with_chevron_and_expression.cpp index 3eeab2643..262e4d6b4 100644 --- a/escher/src/pointer_table_cell_with_chevron_and_expression.cpp +++ b/escher/src/pointer_table_cell_with_chevron_and_expression.cpp @@ -1,8 +1,8 @@ #include #include -PointerTableCellWithChevronAndExpression::PointerTableCellWithChevronAndExpression(char * label, KDText::FontSize size) : - PointerTableCellWithChevron(label, size), +PointerTableCellWithChevronAndExpression::PointerTableCellWithChevronAndExpression(I18n::Message message, KDText::FontSize size) : + PointerTableCellWithChevron(message, size), m_subtitleView(1.0f, 0.5f, Palette::GreyDark) { } diff --git a/escher/src/pointer_table_cell_with_chevron_and_pointer.cpp b/escher/src/pointer_table_cell_with_chevron_and_pointer.cpp index cd94d53b2..9401b4422 100644 --- a/escher/src/pointer_table_cell_with_chevron_and_pointer.cpp +++ b/escher/src/pointer_table_cell_with_chevron_and_pointer.cpp @@ -2,8 +2,8 @@ #include PointerTableCellWithChevronAndPointer::PointerTableCellWithChevronAndPointer(KDText::FontSize labelSize, KDText::FontSize contentSize) : - PointerTableCellWithChevron(nullptr, labelSize), - m_subtitleView(contentSize, "", 1.0f, 0.5f, Palette::GreyDark) + PointerTableCellWithChevron((I18n::Message)0, labelSize), + m_subtitleView(contentSize, (I18n::Message)0, 1.0f, 0.5f, Palette::GreyDark) { } @@ -17,8 +17,8 @@ void PointerTableCellWithChevronAndPointer::setHighlighted(bool highlight) { m_subtitleView.setBackgroundColor(backgroundColor); } -void PointerTableCellWithChevronAndPointer::setSubtitle(const char * text) { - m_subtitleView.setText(text); +void PointerTableCellWithChevronAndPointer::setSubtitle(I18n::Message text) { + m_subtitleView.setMessage(text); reloadCell(); layoutSubviews(); } diff --git a/escher/src/pointer_table_cell_with_editable_text.cpp b/escher/src/pointer_table_cell_with_editable_text.cpp index 33edd0a51..9e370ba01 100644 --- a/escher/src/pointer_table_cell_with_editable_text.cpp +++ b/escher/src/pointer_table_cell_with_editable_text.cpp @@ -2,9 +2,9 @@ #include #include -PointerTableCellWithEditableText::PointerTableCellWithEditableText(Responder * parentResponder, TextFieldDelegate * textFieldDelegate, char * draftTextBuffer, char * label) : +PointerTableCellWithEditableText::PointerTableCellWithEditableText(Responder * parentResponder, TextFieldDelegate * textFieldDelegate, char * draftTextBuffer, I18n::Message message) : Responder(parentResponder), - PointerTableCell(label), + PointerTableCell(message), m_textField(TextField(this, m_textBody, draftTextBuffer, 255, textFieldDelegate, KDText::FontSize::Large, 1.0f, 0.5f)) { } diff --git a/escher/src/pointer_table_cell_with_pointer.cpp b/escher/src/pointer_table_cell_with_pointer.cpp index 90a23f935..6fa5d2059 100644 --- a/escher/src/pointer_table_cell_with_pointer.cpp +++ b/escher/src/pointer_table_cell_with_pointer.cpp @@ -1,24 +1,20 @@ #include #include -PointerTableCellWithPointer::PointerTableCellWithPointer(char * label, Layout layout) : - PointerTableCell(label, KDText::FontSize::Small, layout), - m_accessoryView(PointerTextView(KDText::FontSize::Small, nullptr, 0.0f, 0.5f)) +PointerTableCellWithPointer::PointerTableCellWithPointer(I18n::Message message, Layout layout) : + PointerTableCell(message, KDText::FontSize::Small, layout), + m_accessoryView(PointerTextView(KDText::FontSize::Small, (I18n::Message)0, 0.0f, 0.5f)) { if (layout != Layout::Vertical) { m_accessoryView.setAlignment(1.0f, 0.5f); } } -void PointerTableCellWithPointer::setAccessoryText(const char * textBody) { - m_accessoryView.setText(textBody); +void PointerTableCellWithPointer::setAccessoryMessage(I18n::Message textBody) { + m_accessoryView.setMessage(textBody); reloadCell(); } -const char * PointerTableCellWithPointer::accessoryText() { - return m_accessoryView.text(); -} - View * PointerTableCellWithPointer::accessoryView() const { return (View *)&m_accessoryView; } diff --git a/escher/src/pointer_table_cell_with_switch.cpp b/escher/src/pointer_table_cell_with_switch.cpp index fadb2ac36..749a4e004 100644 --- a/escher/src/pointer_table_cell_with_switch.cpp +++ b/escher/src/pointer_table_cell_with_switch.cpp @@ -1,8 +1,8 @@ #include #include -PointerTableCellWithSwitch::PointerTableCellWithSwitch(char * label) : - PointerTableCell(label), +PointerTableCellWithSwitch::PointerTableCellWithSwitch(I18n::Message message) : + PointerTableCell(message), m_accessoryView(SwitchView()) { } diff --git a/escher/src/pointer_text_view.cpp b/escher/src/pointer_text_view.cpp index ba1cd61d3..528596270 100644 --- a/escher/src/pointer_text_view.cpp +++ b/escher/src/pointer_text_view.cpp @@ -1,17 +1,22 @@ #include +#include -PointerTextView::PointerTextView(KDText::FontSize size, const char * text, float horizontalAlignment, float verticalAlignment, +PointerTextView::PointerTextView(KDText::FontSize size, I18n::Message message, float horizontalAlignment, float verticalAlignment, KDColor textColor, KDColor backgroundColor) : TextView(size, horizontalAlignment, verticalAlignment, textColor, backgroundColor), - m_textPointer(text) + m_message(message) { } const char * PointerTextView::text() const { - return m_textPointer; + return I18n::translate(m_message); } void PointerTextView::setText(const char * text) { - m_textPointer = text; + assert(false); +} + +void PointerTextView::setMessage(I18n::Message message) { + m_message = message; markRectAsDirty(bounds()); -} \ No newline at end of file +} diff --git a/escher/src/stack_view.cpp b/escher/src/stack_view.cpp index 7b7e1c8a8..f1e0e809b 100644 --- a/escher/src/stack_view.cpp +++ b/escher/src/stack_view.cpp @@ -4,39 +4,28 @@ extern "C" { } StackView::StackView() : - View(), - m_textView(PointerTextView(KDText::FontSize::Small, nullptr, 0.5f, 0.5f)) + View() { } void StackView::setTextColor(KDColor textColor) { - m_textView.setTextColor(textColor); + m_textColor = textColor; + markRectAsDirty(bounds()); } void StackView::setBackgroundColor(KDColor backgroundColor) { - m_textView.setBackgroundColor(backgroundColor); m_backgroundColor = backgroundColor; + markRectAsDirty(bounds()); } void StackView::setSeparatorColor(KDColor separatorColor) { m_separatorColor = separatorColor; + markRectAsDirty(bounds()); } -int StackView::numberOfSubviews() const { - return 1; -} - -View * StackView::subviewAtIndex(int index) { - assert(index == 0); - return &m_textView; -} - -void StackView::layoutSubviews() { - m_textView.setFrame(KDRect(0, 1, bounds().width(), bounds().height()-2)); -} - -void StackView::setName(const char * name) { - m_textView.setText(name); +void StackView::setNamedController(ViewController * controller) { + m_controller = controller; + markRectAsDirty(bounds()); } void StackView::drawRect(KDContext * ctx, KDRect rect) const { @@ -45,6 +34,10 @@ void StackView::drawRect(KDContext * ctx, KDRect rect) const { ctx->fillRect(KDRect(0, 0, width, 1), m_separatorColor); ctx->fillRect(KDRect(0, 1, width, height-2), m_backgroundColor); ctx->fillRect(KDRect(0, height-1, width, 1), m_separatorColor); + // Write title + KDSize textSize = KDText::stringSize(m_controller->title(), KDText::FontSize::Small); + KDPoint origin(0.5f*(m_frame.width() - textSize.width()),0.5f*(m_frame.height() - textSize.height())); + ctx->drawString(m_controller->title(), origin, KDText::FontSize::Small, m_textColor, m_backgroundColor); } #if ESCHER_VIEW_LOGGING diff --git a/escher/src/stack_view_controller.cpp b/escher/src/stack_view_controller.cpp index 84295a3e8..669ea9918 100644 --- a/escher/src/stack_view_controller.cpp +++ b/escher/src/stack_view_controller.cpp @@ -18,8 +18,8 @@ void StackViewController::ControllerView::setContentView(View * view) { markRectAsDirty(bounds()); } -void StackViewController::ControllerView::pushStack(const char * name, KDColor textColor, KDColor backgroundColor, KDColor separatorColor) { - m_stackViews[m_numberOfStacks].setName(name); +void StackViewController::ControllerView::pushStack(ViewController * controller, KDColor textColor, KDColor backgroundColor, KDColor separatorColor) { + m_stackViews[m_numberOfStacks].setNamedController(controller); m_stackViews[m_numberOfStacks].setTextColor(textColor); m_stackViews[m_numberOfStacks].setBackgroundColor(backgroundColor); m_stackViews[m_numberOfStacks].setSeparatorColor(separatorColor); @@ -78,17 +78,17 @@ StackViewController::StackViewController(Responder * parentResponder, ViewContro // push(rootViewController); } -const char * StackViewController::title() const { +const char * StackViewController::title() { if (m_rootViewController) { return m_rootViewController->title(); } else { - ViewController * vc = m_children[m_numberOfChildren-1]; + ViewController * vc = m_children[0]; return vc->title(); } } void StackViewController::push(ViewController * vc, KDColor textColor, KDColor backgroundColor, KDColor separatorColor) { - m_view.pushStack(vc->title(), textColor, backgroundColor, separatorColor); + m_view.pushStack(vc, textColor, backgroundColor, separatorColor); m_children[m_numberOfChildren++] = vc; if (m_numberOfChildren > 1) { m_children[m_numberOfChildren-2]->viewWillDisappear(); diff --git a/escher/src/tab_view.cpp b/escher/src/tab_view.cpp index b15988edb..46c458810 100644 --- a/escher/src/tab_view.cpp +++ b/escher/src/tab_view.cpp @@ -23,12 +23,11 @@ void TabView::drawRect(KDContext * ctx, KDRect rect) const { ctx->fillRect(KDRect(0, height-k_activeTabHeight, width, k_activeTabHeight), KDColorWhite); } -void TabView::addTabNamed(const char * name) { +void TabView::addTab(ViewController * controller) { assert(m_numberOfTabs < k_maxNumberOfTabs); uint8_t tabIndex = m_numberOfTabs; - m_cells[tabIndex].setName(name); + m_cells[tabIndex].setNamedController(controller); m_numberOfTabs++; - //setSubview(&m_cells[tabIndex], tabIndex); markRectAsDirty(bounds()); } diff --git a/escher/src/tab_view_cell.cpp b/escher/src/tab_view_cell.cpp index e6a57109e..c085d2153 100644 --- a/escher/src/tab_view_cell.cpp +++ b/escher/src/tab_view_cell.cpp @@ -8,12 +8,12 @@ TabViewCell::TabViewCell() : View(), m_active(false), m_selected(false), - m_name(nullptr) + m_controller(nullptr) { } -void TabViewCell::setName(const char * name) { - m_name = name; +void TabViewCell::setNamedController(ViewController * controller) { + m_controller = controller; markRectAsDirty(bounds()); } @@ -28,7 +28,7 @@ void TabViewCell::setSelected(bool selected) { } KDSize TabViewCell::minimalSizeForOptimalDisplay() const { - return KDText::stringSize(m_name, KDText::FontSize::Small); + return KDText::stringSize(m_controller->title(), KDText::FontSize::Small); } void TabViewCell::drawRect(KDContext * ctx, KDRect rect) const { @@ -46,9 +46,9 @@ void TabViewCell::drawRect(KDContext * ctx, KDRect rect) const { ctx->fillRect(KDRect(0, 0, width, height), background); } // Write title - KDSize textSize = KDText::stringSize(m_name, KDText::FontSize::Small); + KDSize textSize = KDText::stringSize(m_controller->title(), KDText::FontSize::Small); KDPoint origin(0.5f*(m_frame.width() - textSize.width()),0.5f*(m_frame.height() - textSize.height())); - ctx->drawString(m_name, origin, KDText::FontSize::Small, text, background); + ctx->drawString(m_controller->title(), origin, KDText::FontSize::Small, text, background); } #if ESCHER_VIEW_LOGGING @@ -59,6 +59,6 @@ const char * TabViewCell::className() const { void TabViewCell::logAttributes(std::ostream &os) const { View::logAttributes(os); os << " active=\"" << m_active << "\""; - os << " name=\"" << m_name << "\""; + os << " name=\"" << m_controller->title() << "\""; } #endif diff --git a/escher/src/tab_view_controller.cpp b/escher/src/tab_view_controller.cpp index 1b946dd59..88cc647fb 100644 --- a/escher/src/tab_view_controller.cpp +++ b/escher/src/tab_view_controller.cpp @@ -138,7 +138,7 @@ View * TabViewController::view() { // Let's populate our tabview if (m_view.m_tabView.numberOfTabs() != m_numberOfChildren) { for (int i=0; ititle()); + m_view.m_tabView.addTab(m_children[i]); } } return &m_view; diff --git a/escher/src/view_controller.cpp b/escher/src/view_controller.cpp index 934018ab8..8aeaecbf5 100644 --- a/escher/src/view_controller.cpp +++ b/escher/src/view_controller.cpp @@ -5,7 +5,7 @@ ViewController::ViewController(Responder * parentResponder) : { } -const char * ViewController::title() const { +const char * ViewController::title() { return nullptr; } diff --git a/escher/src/warning_controller.cpp b/escher/src/warning_controller.cpp index 2ea81ea05..894c57816 100644 --- a/escher/src/warning_controller.cpp +++ b/escher/src/warning_controller.cpp @@ -3,12 +3,12 @@ WarningController::ContentView::ContentView() : SolidColorView(KDColorBlack), - m_textView(PointerTextView(KDText::FontSize::Small, "", 0.5f, 0.5f, KDColorWhite, KDColorBlack)) + m_textView(PointerTextView(KDText::FontSize::Small, (I18n::Message)0, 0.5f, 0.5f, KDColorWhite, KDColorBlack)) { } -void WarningController::ContentView::setLabel(const char * label) { - m_textView.setText(label); +void WarningController::ContentView::setLabel(I18n::Message label) { + m_textView.setMessage(label); } int WarningController::ContentView::numberOfSubviews() const { @@ -28,18 +28,19 @@ KDSize WarningController::ContentView::minimalSizeForOptimalDisplay() const { return KDSize(textSize.width() + k_horizontalMargin, textSize.height() + k_verticalMargin); } -WarningController::WarningController(Responder * parentResponder) : +WarningController::WarningController(Responder * parentResponder, I18n::Message warningMessage) : ViewController(parentResponder), - m_contentView(ContentView()) + m_contentView(ContentView()), + m_warningMessage(warningMessage) { } -void WarningController::setLabel(const char * label) { +void WarningController::setLabel(I18n::Message label) { m_contentView.setLabel(label); } -const char * WarningController::title() const { - return "Attention"; +const char * WarningController::title() { + return I18n::translate(m_warningMessage); } View * WarningController::view() { diff --git a/quiz/Makefile b/quiz/Makefile index 2dce92b8d..2028a6f7c 100644 --- a/quiz/Makefile +++ b/quiz/Makefile @@ -7,7 +7,7 @@ $(symbols_file): $(tests) @echo "AWK $@" @awk -f quiz/src/symbols.awk $(tests) > $@ -runner_objs += $(addprefix quiz/src/, runner.o symbols.o) +runner_objs += $(addprefix quiz/src/, runner.o symbols.o i18n.o) test_objs = $(subst .c,.o, $(subst .cpp,.o,$(tests))) test.$(EXE): $(runner_objs) $(test_objs) diff --git a/quiz/src/i18n.cpp b/quiz/src/i18n.cpp new file mode 100644 index 000000000..5da271f0c --- /dev/null +++ b/quiz/src/i18n.cpp @@ -0,0 +1,10 @@ +#include + +namespace I18n { + +const char * translate(Message m, Language l) { + return nullptr; +} + +} +