ttcalc/src/languages.cpp

407 lines
18 KiB
C++
Raw Blame History

/*
* This file is a part of TTCalc - a mathematical calculator
* and is distributed under the (new) BSD licence.
* Author: Tomasz Sowa <t.sowa@slimaczek.pl>
*/
/*
* Copyright (c) 2006-2007, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name Tomasz Sowa nor the names of contributors to this
* project may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "compileconfig.h"
#include "languages.h"
const char * Languages::ErrorMessage(Country country, ttmath::ErrorCode code)
{
const char * unk_err = "unknown error";
if( error_messages_tab.empty() )
InitErrorMessagesTab();
unsigned int cid = static_cast<unsigned int>( country );
if( cid >= error_messages_tab.size() )
return unk_err;
std::map<ttmath::ErrorCode, std::string>::const_iterator i;
i = error_messages_tab[cid].find( code );
if( i == error_messages_tab[cid].end() )
return unk_err;
return i->second.c_str();
}
const char * Languages::ErrorMessage(ttmath::ErrorCode code)
{
return ErrorMessage(current_country, code);
}
void Languages::InsertErrorPair(ttmath::ErrorCode code, const char * message)
{
if( error_messages_tab.empty() )
return;
error_messages_tab.back().insert( std::make_pair(code, message) );
}
void Languages::InitErrorMessagesTab()
{
error_messages_tab.push_back( std::map<ttmath::ErrorCode, std::string>() );
InsertErrorPair(ttmath::err_ok,"ok");
InsertErrorPair(ttmath::err_nothing_has_read,"");
InsertErrorPair(ttmath::err_unknown_character,"An unknown character");
InsertErrorPair(ttmath::err_unexpected_final_bracket,"An unexpected final bracket");
InsertErrorPair(ttmath::err_stack_not_clear,"An unknown character has left");
InsertErrorPair(ttmath::err_unknown_variable,"An unknown variable");
InsertErrorPair(ttmath::err_division_by_zero,"Division by zero");
InsertErrorPair(ttmath::err_interrupt,"The calculating has been broken");
InsertErrorPair(ttmath::err_overflow,"Overflow");
InsertErrorPair(ttmath::err_unknown_function,"An unknown function");
InsertErrorPair(ttmath::err_unknown_operator,"An unknown operator");
InsertErrorPair(ttmath::err_unexpected_semicolon_operator,"An unexpected semicolon operator");
InsertErrorPair(ttmath::err_improper_amount_of_arguments,"Improper amount of arguments");
InsertErrorPair(ttmath::err_improper_argument,"Improper argument");
InsertErrorPair(ttmath::err_unexpected_end,"Unexpected end");
InsertErrorPair(ttmath::err_internal_error,"An internal error");
InsertErrorPair(ttmath::err_incorrect_name,"Incorrect name of a variable or function");
InsertErrorPair(ttmath::err_incorrect_value,"Incorrect value of a variable or function");
InsertErrorPair(ttmath::err_variable_exists,"This variable already exists");
InsertErrorPair(ttmath::err_variable_loop,"There's a recurrence between variables");
InsertErrorPair(ttmath::err_functions_loop,"There's a recurrence between functions");
InsertErrorPair(ttmath::err_must_be_only_one_value,"Variables or functions must return only one value");
InsertErrorPair(ttmath::err_still_calculating,"Calculating...");
InsertErrorPair(ttmath::err_too_big_factorial,"A too big argument for the factorial() function");
// pl
error_messages_tab.push_back( std::map<ttmath::ErrorCode, std::string>() );
InsertErrorPair(ttmath::err_ok,"ok");
InsertErrorPair(ttmath::err_nothing_has_read,"");
InsertErrorPair(ttmath::err_unknown_character,"Nieznany znak");
InsertErrorPair(ttmath::err_unexpected_final_bracket,"Nieoczekiwany nawias zamykaj<61>cy");
InsertErrorPair(ttmath::err_stack_not_clear,"Pozosta<EFBFBD> nieznany znak");
InsertErrorPair(ttmath::err_unknown_variable,"Nieznana zmienna");
InsertErrorPair(ttmath::err_division_by_zero,"Dzielenie przez zero");
InsertErrorPair(ttmath::err_interrupt,"Obliczenia zosta<74>y przerwane");
InsertErrorPair(ttmath::err_overflow,"Przekroczony zakres");
InsertErrorPair(ttmath::err_unknown_function,"Nieznana funkcja");
InsertErrorPair(ttmath::err_unknown_operator,"Nieznany operator");
InsertErrorPair(ttmath::err_unexpected_semicolon_operator,"Nieoczekiwany operator '<27>rednik'");
InsertErrorPair(ttmath::err_improper_amount_of_arguments,"Niew<EFBFBD>a<EFBFBD>ciwa liczba argument<6E>w");
InsertErrorPair(ttmath::err_improper_argument,"Niew<EFBFBD>a<EFBFBD>ciwy argument");
InsertErrorPair(ttmath::err_unexpected_end,"Nieoczekiwany koniec");
InsertErrorPair(ttmath::err_internal_error,"B<EFBFBD><EFBFBD>d wewn<77>trzny programu!");
InsertErrorPair(ttmath::err_incorrect_name,"Nieprawid<EFBFBD>owa nazwa zmiennej lub funkcji");
InsertErrorPair(ttmath::err_incorrect_value,"Nieprawid<EFBFBD>owa warto<74><6F> zmiennej lub funkcji");
InsertErrorPair(ttmath::err_variable_exists,"Ta zmienna juz istnieje");
InsertErrorPair(ttmath::err_variable_loop,"Pomi<EFBFBD>dzy zmiennymi zachodzi wywo<77>anie rekurencyjne");
InsertErrorPair(ttmath::err_functions_loop,"Pomi<EFBFBD>dzy funkcjami zachodzi wywo<77>anie rekurencyjne");
InsertErrorPair(ttmath::err_must_be_only_one_value,"Zmienne albo funkcje mog<6F> posiada<64> (zwraca<63>) tylko jedn<64> warto<74><6F>");
InsertErrorPair(ttmath::err_still_calculating,"Obliczanie...");
InsertErrorPair(ttmath::err_too_big_factorial,"Zbyt du<64>y argument dla funkcji factorial()");
}
// for gui messages
const char * Languages::GuiMessage(Country country, GuiMsg code)
{
const char * unk_msg = "unknown";
if( gui_messages_tab.empty() )
InitGuiMessagesTab();
unsigned int cid = static_cast<unsigned int>( country );
if( cid >= gui_messages_tab.size() )
return unk_msg;
std::map<GuiMsg, std::string>::const_iterator i;
i = gui_messages_tab[cid].find( code );
if( i == gui_messages_tab[cid].end() )
return unk_msg;
return i->second.c_str();
}
const char * Languages::GuiMessage(GuiMsg code)
{
return GuiMessage(current_country, code);
}
void Languages::InsertGuiPair(GuiMsg code, const char * message)
{
if( gui_messages_tab.empty() )
return;
gui_messages_tab.back().insert( std::make_pair(code, message) );
}
void Languages::InitGuiMessagesTab()
{
// en
gui_messages_tab.push_back( std::map<GuiMsg, std::string>() );
InsertGuiPair(button_ok,"Ok");
InsertGuiPair(button_cancel,"Cancel");
InsertGuiPair(message_box_caption,"TTCalc");
InsertGuiPair(dialog_box_add_variable_caption,"Add a new variable");
InsertGuiPair(dialog_box_edit_variable_caption,"Edit a variable");
InsertGuiPair(dialog_box_add_variable_incorrect_name,"An incorrect name of the variable");
InsertGuiPair(dialog_box_add_variable_incorrect_value,"An incorrect value of the variable");
InsertGuiPair(dialog_box_add_variable_variable_exists,"This variable already exists");
InsertGuiPair(dialog_box_edit_variable_unknown_variable,"There isn't this variable in my table. There's probably an internal error!");
InsertGuiPair(dialog_box_delete_variable_confirm,"Do you want to delete these variables?");
InsertGuiPair(dialog_box_variable_not_all_deleted,"There are some variables which I was not able to delete. Probably an internal error!");
InsertGuiPair(dialog_box_add_function_caption,"Add a new function");
InsertGuiPair(dialog_box_edit_function_caption,"Edit a function");
InsertGuiPair(dialog_box_add_function_function_exists,"This function already exists");
InsertGuiPair(dialog_box_edit_function_unknown_function,"There isn't this function in my table. There's probably an internal error!");
InsertGuiPair(dialog_box_delete_function_confirm,"Do you want to delete these functions?");
InsertGuiPair(dialog_box_function_not_all_deleted,"There are some functions which I was not able to delete. Probably an internal error!");
InsertGuiPair(dialog_box_add_function_incorrect_name,"An incorrect name of the function");
InsertGuiPair(list_variables_header_1,"Name");
InsertGuiPair(list_variables_header_2,"Value");
InsertGuiPair(list_functions_header_1,"Name");
InsertGuiPair(list_functions_header_2,"Param.");
InsertGuiPair(list_functions_header_3,"Value");
InsertGuiPair(button_add,"Add");
InsertGuiPair(button_edit,"Edit");
InsertGuiPair(button_delete,"Delete");
InsertGuiPair(button_clear,"C");
InsertGuiPair(tab_standard,"Standard");
InsertGuiPair(tab_variables,"Variables");
InsertGuiPair(tab_functions,"Functions");
InsertGuiPair(tab_precision,"Precision");
InsertGuiPair(tab_display,"Display");
InsertGuiPair(radio_precision_1,"Small - 96 bits for the mantissa, 32 bits for the exponent");
InsertGuiPair(radio_precision_2,"Medium - 192 bits for the mantissa, 64 bits for the exponent");
InsertGuiPair(radio_precision_3,"Big - 288 bits for the mantissa, 96 bits for the exponent");
InsertGuiPair(precision_1_info,"(+/-)6.9 e+646457021, 26 valid digits (decimal)");
InsertGuiPair(precision_2_info,"(+/-)4.3 e+2776511644261678623, 56 valid digits");
InsertGuiPair(precision_3_info,"(+/-)2.5 e+11925026709067095507636213441, 85 valid digits");
InsertGuiPair(overflow_during_printing,"Overflow during printing");
InsertGuiPair(combo_rounding_none,"None");
InsertGuiPair(combo_rounding_cut_last_digits,"Cut off last non-valid digits");
InsertGuiPair(combo_rounding_integer,"Round to the nearest integer");
InsertGuiPair(combo_rounding_to_number,"to");
InsertGuiPair(combo_rounding_after_comma,"digit(s) after comma");
InsertGuiPair(display_input, "Input");
InsertGuiPair(display_output, "Output");
InsertGuiPair(display_rounding, "Rounding");
InsertGuiPair(display_always_scientific,"Always");
InsertGuiPair(display_not_always_scientific,"When the exponent is greater than:");
InsertGuiPair(display_group_scientific, "Print the result as the scientific value");
InsertGuiPair(menu_view, "&View");
InsertGuiPair(menu_edit, "&Edit");
InsertGuiPair(menu_help, "&Help");
InsertGuiPair(menu_language, "&Language");
InsertGuiPair(menu_view_new_window, "&New window");
InsertGuiPair(menu_view_normal_view, "No&rmal view");
InsertGuiPair(menu_view_compact_view, "C&ompact view");
InsertGuiPair(menu_view_always_on_top, "&Always on top");
InsertGuiPair(menu_view_lang_english, "&English");
InsertGuiPair(menu_view_lang_polish, "&Polish");
InsertGuiPair(menu_view_close_program, "&Close");
InsertGuiPair(menu_edit_undo, "&Undo");
InsertGuiPair(menu_edit_paste, "&Paste");
InsertGuiPair(menu_edit_copy_result, "&Copy the result");
InsertGuiPair(menu_help_help, "&Help");
InsertGuiPair(menu_help_project_page, "&Project page");
InsertGuiPair(menu_help_about, "&About");
InsertGuiPair(cant_init_calculations, "I could not initialize the module of calculations");
InsertGuiPair(message_box_error_caption,"TTCalc");
InsertGuiPair(cant_create_thread, "I could not create the second thread for calculating");
InsertGuiPair(cant_create_main_window, "I could not create the main window of the application");
InsertGuiPair(cant_init_common_controls,"I could not initialize the common controls (InitCommonControlsEx)");
InsertGuiPair(about_text,
"Mathematical calculator TTCalc %d.%d.%d%s\r\n"
"Author: Tomasz Sowa\r\n"
"Contact: t.sowa@slimaczek.pl\r\n"
"Licence: (New) BSD licence\r\n"
"Project page: http://sourceforge.net/projects/ttcalc\r\n"
"Bignum library: TTMath %d.%d.%d%s\r\n"
"Programming language: C++\r\n"
"Compiler: %s\r\n"
"\r\n"
"This program uses the TTMath bignum library"
" which can be found at http://sourceforge.net/projects/ttmath\r\n"
"\r\n"
"If you have any questions, advices or interesting ideas about"
" this program or if you want to join to this project as"
" a developer or programmer feel free to contant with the author."
);
InsertGuiPair(about_box_title, "About");
InsertGuiPair(about_box_button_close, "Close");
InsertGuiPair(unknown_error, "An unknown error has occurred");
InsertGuiPair(cant_find_help, "I can't find any help files");
InsertGuiPair(cant_open_project_page, "I can't open the project webpage");
// pl
gui_messages_tab.push_back( std::map<GuiMsg, std::string>() );
InsertGuiPair(button_ok,"Ok");
InsertGuiPair(button_cancel,"Anuluj");
InsertGuiPair(message_box_caption,"TTCalc");
InsertGuiPair(dialog_box_add_variable_caption,"Dodaj now<6F> zmienn<6E>");
InsertGuiPair(dialog_box_edit_variable_caption,"Zmie<EFBFBD> warto<74><6F> zmiennej");
InsertGuiPair(dialog_box_add_variable_incorrect_name,"Nie prawid<69>owa nazwa zmiennej");
InsertGuiPair(dialog_box_add_variable_incorrect_value,"Nie prawid<69>owa warto<74><6F> zmiennej");
InsertGuiPair(dialog_box_add_variable_variable_exists,"Podana zmienna ju<6A> istnieje");
InsertGuiPair(dialog_box_edit_variable_unknown_variable,"Podanej zmiennej nie ma w tablicy. Prawdopodobnie b<><62>d wewn<77>trzny programu.");
InsertGuiPair(dialog_box_delete_variable_confirm,"Czy napewno usun<75><6E> zaznaczone zmienne?");
InsertGuiPair(dialog_box_variable_not_all_deleted,"Zosta<EFBFBD>o kilka zmiennych kt<6B>rych nie mo<6D>na by<62>o skasowa<77>. Prawdopodobnie b<><62>d wewn<77>trzny programu.");
InsertGuiPair(dialog_box_add_function_caption,"Dodaj now<6F> funkcj<63>");
InsertGuiPair(dialog_box_edit_function_caption,"Zmie<EFBFBD> warto<74><6F> funkcji");
InsertGuiPair(dialog_box_add_function_function_exists,"Podana funkcja ju<6A> istnieje");
InsertGuiPair(dialog_box_edit_function_unknown_function,"Podanej funkcji nie ma w tablicy. Prawdopodobnie b<><62>d wewn<77>trzny programu.");
InsertGuiPair(dialog_box_delete_function_confirm,"Czy napewno usun<75><6E> zaznaczone funkcje?");
InsertGuiPair(dialog_box_function_not_all_deleted,"Zosta<EFBFBD>o kilka funkcji kt<6B>rych nie mo<6D>na by<62>o skasowa<77>. Prawdopodobnie b<><62>d wewn<77>trzny programu.");
InsertGuiPair(dialog_box_add_function_incorrect_name,"Nieprawid<EFBFBD>owa nazwa funkcji");
InsertGuiPair(list_variables_header_1,"Nazwa");
InsertGuiPair(list_variables_header_2,"Warto<EFBFBD><EFBFBD>");
InsertGuiPair(list_functions_header_1,"Nazwa");
InsertGuiPair(list_functions_header_2,"Parametry");
InsertGuiPair(list_functions_header_3,"Warto<EFBFBD><EFBFBD>");
InsertGuiPair(button_add,"Dodaj");
InsertGuiPair(button_edit,"Edytuj");
InsertGuiPair(button_delete,"Usu<EFBFBD>");
InsertGuiPair(button_clear,"C");
InsertGuiPair(tab_standard,"Standard");
InsertGuiPair(tab_variables,"Zmienne");
InsertGuiPair(tab_functions,"Funkcje");
InsertGuiPair(tab_precision,"Precyzja");
InsertGuiPair(tab_display,"Wy<EFBFBD>wietlanie");
InsertGuiPair(radio_precision_1,"Ma<EFBFBD>a - 96 bitowa mantysa, 32 bitowy wyk<79>adnik");
InsertGuiPair(radio_precision_2,"<EFBFBD>rednia - 192 bitowa mantysa, 64 bitowy wyk<79>adnik");
InsertGuiPair(radio_precision_3,"Du<EFBFBD>a - 288 bitowa mantysa, 96 bitowy wyk<79>adnik");
InsertGuiPair(precision_1_info,"(+/-)6.9 e+646457021, 26 cyfr znacz<63>cych (w rozwini<6E>ciu dziesi<73>tnym)");
InsertGuiPair(precision_2_info,"(+/-)4.3 e+2776511644261678623, 56 cyfr znacz<63>cych");
InsertGuiPair(precision_3_info,"(+/-)2.5 e+11925026709067095507636213441, 85 cyfr znacz<63>cych");
InsertGuiPair(overflow_during_printing,"Przepe<EFBFBD>nienie podczas wypisywania");
InsertGuiPair(combo_rounding_none,"bez zaokr<6B>glania");
InsertGuiPair(combo_rounding_cut_last_digits,"skasowa<EFBFBD> nie znacz<63>ce zera");
InsertGuiPair(combo_rounding_integer,"do najbli<6C>szej ca<63>kowitej");
InsertGuiPair(combo_rounding_to_number,"do");
InsertGuiPair(combo_rounding_after_comma,"cyfr(y) po przecinku");
InsertGuiPair(display_input,"Wej<EFBFBD>cie");
InsertGuiPair(display_output,"Wyj<EFBFBD>cie");
InsertGuiPair(display_rounding,"Zaokr<EFBFBD>glenie");
InsertGuiPair(display_always_scientific,"Zawsze");
InsertGuiPair(display_not_always_scientific,"Je<EFBFBD>li eksponent jest wi<77>kszy ni<6E>:");
InsertGuiPair(display_group_scientific, "Wy<EFBFBD>wietl wynik w postaci naukowej");
InsertGuiPair(menu_view, "&Widok");
InsertGuiPair(menu_edit, "&Edycja");
InsertGuiPair(menu_help, "&Pomoc");
InsertGuiPair(menu_language, "&J<>zyk");
InsertGuiPair(menu_view_new_window, "&Nowe okno");
InsertGuiPair(menu_view_normal_view, "Widok no&rmalny");
InsertGuiPair(menu_view_compact_view, "Widok &kompaktowy");
InsertGuiPair(menu_view_always_on_top, "Zawsze na &wierzchu");
InsertGuiPair(menu_view_lang_english, "J<EFBFBD>zyk &angielski");
InsertGuiPair(menu_view_lang_polish, "J<EFBFBD>zyk &polski");
InsertGuiPair(menu_view_close_program, "&Zamknij");
InsertGuiPair(menu_edit_undo, "&Cofnij");
InsertGuiPair(menu_edit_paste, "&Wklej");
InsertGuiPair(menu_edit_copy_result, "&Kopiuj wynik");
InsertGuiPair(menu_help_help, "&Pomoc");
InsertGuiPair(menu_help_project_page, "&Strona projektu");
InsertGuiPair(menu_help_about, "&O programie");
InsertGuiPair(cant_init_calculations, "Nie uda<64>o si<73> zainicjalizowa<77> modu<64>u obs<62>ugi oblicze<7A>");
InsertGuiPair(message_box_error_caption,"TTCalc");
InsertGuiPair(cant_create_thread, "Nie uda<64>o si<73> utworzy<7A> drugiego w<>tku do oblicze<7A>");
InsertGuiPair(cant_create_main_window, "Nie uda<64>o si<73> utworzy<7A> g<><67>wnego okna aplikacji");
InsertGuiPair(cant_init_common_controls,"Nie uda<64>o si<73> zainicjalizowa<77> obs<62>ugi Common Controls (InitCommonControlsEx)");
InsertGuiPair(about_text,
"Kalkulator matematyczny TTCalc %d.%d.%d%s\r\n"
"Autor: Tomasz Sowa\r\n"
"Kontakt: t.sowa@slimaczek.pl\r\n"
"Licencja: (New) BSD\r\n"
"Strona projektu: http://sourceforge.net/projects/ttcalc\r\n"
"Biblioteka du<64>ych liczb: TTMath %d.%d.%d%s\r\n"
"J<EFBFBD>zyk programowania: C++\r\n"
"Kompilator: %s\r\n"
"\r\n"
"Ten program u<>ywa biblioteki du<64>ych liczb TTMath"
" kt<6B>ra jest dost<73>pna na http://sourceforge.net/projects/ttmath\r\n"
"\r\n"
"Je<EFBFBD>eli masz jakie<69> pytania, rady, ciekawe pomys<79>y dotycz<63>ce"
" tego programu lub chcia<69>by<62> do<64><6F>czy<7A> jako projektant/programista"
" poprostu skontaktuj si<73> z autorem."
);
InsertGuiPair(about_box_title, "O programie");
InsertGuiPair(about_box_button_close, "Zamknij");
InsertGuiPair(unknown_error, "Nieznany kod b<><62>du");
InsertGuiPair(cant_find_help, "Nie mog<6F> znale<6C><65> <20>adnych plik<69>w pomocy");
InsertGuiPair(cant_open_project_page, "Nie mog<6F> otworzy<7A> strony projektu");
}