mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 13:06:59 -04:00
Localisation, using Locale class
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@113 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
+3
-4
@@ -36,8 +36,7 @@ class Error {
|
||||
class InternalError : public Error {
|
||||
public:
|
||||
inline InternalError(const String& str)
|
||||
: Error(_("An internal error occured:\n\n") + str
|
||||
+_("\n\nPlease save your work (use 'save as' to so you don't overwrite things),\n and restart Magic Set Editor.\n\nYou should leave a bug report on http://magicseteditor.sourceforge.net/"))
|
||||
: Error(_ERROR_1_("internal error",str))
|
||||
{}
|
||||
};
|
||||
|
||||
@@ -53,7 +52,7 @@ class PackageError : public Error {
|
||||
class FileNotFoundError : public PackageError {
|
||||
public:
|
||||
inline FileNotFoundError(const String& file, const String& package)
|
||||
: PackageError(_("File not found: ") + file + _(" in package ") + package)
|
||||
: PackageError(_ERROR_2_("file not found",file,package))
|
||||
{}
|
||||
};
|
||||
|
||||
@@ -69,7 +68,7 @@ class ParseError : public Error {
|
||||
class FileParseError : public ParseError {
|
||||
public:
|
||||
inline FileParseError(const String& err, const String& file) :
|
||||
ParseError(_("Error while parsing file '") + file + _("':\n") + err)
|
||||
ParseError(_ERROR_2_("file parse error",file,err))
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
@@ -308,9 +308,9 @@ void Package::openZipfile() {
|
||||
delete zipStream; zipStream = nullptr;
|
||||
// open streams
|
||||
fileStream = new wxFileInputStream(filename);
|
||||
if (!fileStream->IsOk()) throw PackageError(_("Package not found: '")+filename+_("'"));
|
||||
if (!fileStream->IsOk()) throw PackageError(_ERROR_1_("package not found", filename));
|
||||
zipStream = new wxZipInputStream(*fileStream);
|
||||
if (!zipStream->IsOk()) throw PackageError(_("Package not found: '")+filename+_("'"));
|
||||
if (!zipStream->IsOk()) throw PackageError(_ERROR_1_("package not found", filename));
|
||||
// read zip entries
|
||||
while (true) {
|
||||
wxZipEntry* entry = zipStream->GetNextEntry();
|
||||
@@ -333,12 +333,12 @@ void Package::saveToDirectory(const String& saveAs, bool removeUnused) {
|
||||
// move files that were updated
|
||||
wxRemoveFile(saveAs+_("/")+f.first);
|
||||
if (!wxRenameFile(f.second.tempName, saveAs+_("/")+f.first)) {
|
||||
throw PackageError(_("Error while saving, unable to store file"));
|
||||
throw PackageError(_ERROR_("unable to store file"));
|
||||
}
|
||||
} else if (filename != saveAs) {
|
||||
// save as, copy old filess
|
||||
if (!wxCopyFile(filename+_("/")+f.first, saveAs+_("/")+f.first)) {
|
||||
throw PackageError(_("Error while saving, unable to store file"));
|
||||
throw PackageError(_ERROR_("unable to store file"));
|
||||
}
|
||||
} else {
|
||||
// old file, just keep it
|
||||
@@ -353,9 +353,9 @@ void Package::saveToZipfile(const String& saveAs, bool removeUnused) {
|
||||
// open zip file
|
||||
try {
|
||||
scoped_ptr<wxFileOutputStream> newFile(new wxFileOutputStream(tempFile));
|
||||
if (!newFile->IsOk()) throw PackageError(_("Error while saving, unable to open output file"));
|
||||
if (!newFile->IsOk()) throw PackageError(_ERROR_("unable to open output file"));
|
||||
scoped_ptr<wxZipOutputStream> newZip(new wxZipOutputStream(*newFile));
|
||||
if (!newZip->IsOk()) throw PackageError(_("Error while saving, unable to open output file"));
|
||||
if (!newZip->IsOk()) throw PackageError(_ERROR_("unable to open output file"));
|
||||
// copy everything to a new zip file, unless it's updated or removed
|
||||
if (zipStream) newZip->CopyArchiveMetaData(*zipStream);
|
||||
FOR_EACH(f, files) {
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <data/game.hpp>
|
||||
#include <data/stylesheet.hpp>
|
||||
#include <data/symbol_font.hpp>
|
||||
#include <data/locale.hpp>
|
||||
#include <wx/stdpaths.h>
|
||||
|
||||
// ----------------------------------------------------------------------------- : IncludePackage
|
||||
@@ -68,7 +69,7 @@ PackagedP PackageManager::openAny(const String& name) {
|
||||
// load with the right type, based on extension
|
||||
if (fn.GetExt() == _("mse-game")) p = new_shared<Game>();
|
||||
else if (fn.GetExt() == _("mse-style")) p = new_shared<StyleSheet>();
|
||||
// else if (fn.GetExt() == _("mse-locale")) p = new_shared<Locale>();
|
||||
else if (fn.GetExt() == _("mse-locale")) p = new_shared<Locale>();
|
||||
else if (fn.GetExt() == _("mse-include")) p = new_shared<IncludePackage>();
|
||||
else if (fn.GetExt() == _("mse-symbol-font")) p = new_shared<SymbolFont>();
|
||||
else {
|
||||
|
||||
@@ -42,12 +42,7 @@ void Reader::handleAppVersion() {
|
||||
if (enterBlock(_("mse_version"))) {
|
||||
handle(file_app_version);
|
||||
if (app_version < file_app_version) {
|
||||
wxMessageBox(
|
||||
filename + _("\n")
|
||||
_("This file is made with a newer version of Magic Set Editor (")+ file_app_version.toString() +_(").\n")
|
||||
_("When you open it, some aspects of the file may be lost.\n")
|
||||
_("It is recommended that you upgrade to the latest version.\n")
|
||||
_("Visit http:://magicseteditor.sourceforge.net/"), _("Warning"), wxOK | wxICON_EXCLAMATION);
|
||||
wxMessageBox(_ERROR_2_("newer version", filename, file_app_version.toString()), _("Warning"), wxOK | wxICON_EXCLAMATION);
|
||||
}
|
||||
exitBlock();
|
||||
}
|
||||
|
||||
@@ -225,7 +225,7 @@ void Reader::handle(IndexMap<K,V>& m) {
|
||||
reflect_ ## Enum(enum_, reader); \
|
||||
if (!reader.isDone()) { \
|
||||
/* warning: unknown value */ \
|
||||
warning(_("Unrecognized value: ") + value); \
|
||||
warning(_ERROR_1_("unrecognized value", value)); \
|
||||
} \
|
||||
} \
|
||||
bool parse_enum(const String& value, Enum& out) { \
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
//+----------------------------------------------------------------------------+
|
||||
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
|
||||
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
|
||||
//| License: GNU General Public License 2 or later (see file COPYING) |
|
||||
//+----------------------------------------------------------------------------+
|
||||
|
||||
#ifndef HEADER_UTIL_LOCALE
|
||||
#define HEADER_UTIL_LOCALE
|
||||
|
||||
/** @file util/locale.hpp
|
||||
*
|
||||
* @brief Utilities for localisation of text.
|
||||
* Whenever text is used that can be translated to another language (and is not code related)
|
||||
* one of the macros from this file should be used
|
||||
*/
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <util/string.hpp>
|
||||
|
||||
// ----------------------------------------------------------------------------- : Localisation macros
|
||||
|
||||
enum LocaleCategory
|
||||
{ LOCALE_CAT_MENU
|
||||
, LOCALE_CAT_HELP
|
||||
, LOCALE_CAT_TOOL
|
||||
, LOCALE_CAT_LABEL
|
||||
, LOCALE_CAT_BUTTON
|
||||
, LOCALE_CAT_TYPE
|
||||
, LOCALE_CAT_ACTION
|
||||
, LOCALE_CAT_ERROR
|
||||
, LOCALE_CAT_MAX
|
||||
};
|
||||
|
||||
/// Translate 'key' in the category 'cat' using the current locale
|
||||
String tr(LocaleCategory cat, const String& key);
|
||||
|
||||
/// A localized string for menus/toolbar buttons
|
||||
#define _MENU_(s) tr(LOCALE_CAT_MENU, _(s))
|
||||
/// A localized string for help/statusbar text
|
||||
#define _HELP_(s) tr(LOCALE_CAT_HELP, _(s))
|
||||
/// A localized string for tooltip text for toolbar buttons
|
||||
#define _TOOL_(s) tr(LOCALE_CAT_TOOL, _(s))
|
||||
/// A localized string for labels
|
||||
#define _LABEL_(s) tr(LOCALE_CAT_LABEL, _(s))
|
||||
/// A localized string for buttons
|
||||
#define _BUTTON_(s) tr(LOCALE_CAT_BUTTON,_(s))
|
||||
/// A localized string for type names in scripts
|
||||
#define _TYPE_(s) tr(LOCALE_CAT_TYPE, _(s))
|
||||
/// A localized string for action names
|
||||
#define _ACTION_(s) tr(LOCALE_CAT_ACTION, _(s))
|
||||
/// A localized string for error messages
|
||||
#define _ERROR_(s) tr(LOCALE_CAT_ERROR, _(s))
|
||||
|
||||
/// A localized string for error messages, with 1 argument (printf style)
|
||||
#define _ERROR_1_(s,a) String::Format(tr(LOCALE_CAT_ERROR, _(s)), a)
|
||||
/// A localized string for error messages, with 2 argument (printf style)
|
||||
#define _ERROR_2_(s,a,b) String::Format(tr(LOCALE_CAT_ERROR, _(s)), a, b)
|
||||
/// A localized string for error messages, with 3 argument (printf style)
|
||||
#define _ERROR_3_(s,a,b,c) String::Format(tr(LOCALE_CAT_ERROR, _(s)), a, b, c)
|
||||
|
||||
// ----------------------------------------------------------------------------- : EOF
|
||||
#endif
|
||||
@@ -39,6 +39,7 @@ using namespace std;
|
||||
#include "string.hpp"
|
||||
#include "smart_ptr.hpp"
|
||||
#include "index_map.hpp"
|
||||
#include "locale.hpp"
|
||||
|
||||
// ----------------------------------------------------------------------------- : Wx Aliasses
|
||||
|
||||
|
||||
Reference in New Issue
Block a user