[apps][escher] I18n

Change-Id: I4d6f40155a8a182184af9ef2a583d0469196ffd5
This commit is contained in:
Émilie Feral
2017-03-14 16:21:36 +01:00
parent a1442674c7
commit adc80cd71b
207 changed files with 1384 additions and 669 deletions

View File

@@ -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\

View File

@@ -9,7 +9,7 @@ AppsWindow::AppsWindow() :
{
}
void AppsWindow::setTitle(const char * title) {
void AppsWindow::setTitle(I18n::Message title) {
m_titleBarView.setTitle(title);
}

View File

@@ -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:

View File

@@ -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)),

View File

@@ -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();
}

View File

@@ -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();

View File

@@ -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();
}

View File

@@ -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();

View File

@@ -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;
}

View File

@@ -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

View File

@@ -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)),

View File

@@ -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) {

View File

@@ -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;

View File

@@ -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() {

View File

@@ -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;

View File

@@ -1,5 +1,6 @@
#include "list_controller.h"
#include "../app.h"
#include "../../i18n.h"
#include <assert.h>
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() {

View File

@@ -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:

View File

@@ -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() {

View File

@@ -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;

View File

@@ -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)
{

View File

@@ -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) {

View File

@@ -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();

View File

@@ -1,5 +1,7 @@
#include "app.h"
#include "../apps_container.h"
#include "../i18n.h"
extern "C" {
#include <assert.h>
}
@@ -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);

View File

@@ -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();
}

View File

@@ -31,6 +31,10 @@ void Controller::didBecomeFirstResponder() {
app()->setFirstResponder(&m_selectableTableView);
}
void Controller::viewWillAppear() {
m_selectableTableView.reloadData();
}
View * Controller::view() {
return &m_selectableTableView;
}

View File

@@ -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;

359
apps/i18n.cpp Normal file
View File

@@ -0,0 +1,359 @@
#include "i18n.h"
#include "global_preferences.h"
#include <assert.h>
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];
}
}

315
apps/i18n.h Normal file
View File

@@ -0,0 +1,315 @@
#ifndef APPS_I18N_H
#define APPS_I18N_H
#include <escher.h>
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

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -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;
};

View File

@@ -12,7 +12,7 @@ View * PicViewController::view() {
/*
const char * PicViewController::title() const {
const char * PicViewController::title() {
return "PicView";
}
*/

View File

@@ -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)
{
}
}
}

View File

@@ -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();

View File

@@ -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) {

View File

@@ -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;

View File

@@ -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) {

View File

@@ -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;

View File

@@ -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) {

View File

@@ -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;

View File

@@ -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)];

View File

@@ -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);

View File

@@ -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) {

View File

@@ -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:

View File

@@ -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;
}
}

View File

@@ -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;

View File

@@ -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() {

View File

@@ -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;

View File

@@ -2,7 +2,9 @@
#define PROBABILITE_LAW_H
#include <poincare.h>
#include <escher.h>
#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;

View File

@@ -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;
}
}

View File

@@ -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;

View File

@@ -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() {

View File

@@ -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;
};

View File

@@ -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;
}
}

View File

@@ -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;

View File

@@ -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) :

View File

@@ -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;

View File

@@ -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);

View File

@@ -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;

View File

@@ -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)),

View File

@@ -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;
}
}

View File

@@ -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;

View File

@@ -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) {

View File

@@ -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;

View File

@@ -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);

View File

@@ -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;

View File

@@ -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=";

View File

@@ -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
#endif

View File

@@ -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]);
}
}

View File

@@ -3,6 +3,7 @@
#include <escher.h>
#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;

View File

@@ -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]);
}
}

View File

@@ -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;

View File

@@ -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),

View File

@@ -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) {

View File

@@ -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;

View File

@@ -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() {

View File

@@ -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;

View File

@@ -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);
}
}

View File

@@ -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;

View File

@@ -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) {

View File

@@ -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;

View File

@@ -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) {

View File

@@ -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;

View File

@@ -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() {

View File

@@ -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;

View File

@@ -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() {

View File

@@ -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;

View File

@@ -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))
{

View File

@@ -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;
}
}

View File

@@ -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;

View File

@@ -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)
{

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;
}
}

View File

@@ -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;
};
}

View File

@@ -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)
{
}

View File

@@ -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;

View File

@@ -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());

View File

@@ -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);

Some files were not shown because too many files have changed in this diff Show More