mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
Locale now sneakily also recognizes lines marked as #_ADD
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1101 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
mse version: 0.3.7
|
||||
mse version: 0.3.7
|
||||
installer group: translations/Simplified Chinese
|
||||
full name: 简体中文 (Simplified Chinese)
|
||||
version: 2008-07-03
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
mse version: 0.3.7
|
||||
mse version: 0.3.7
|
||||
installer group: translations/Deutsch
|
||||
full name: Deutsch
|
||||
version: 2008-07-24
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
mse version: 0.3.7
|
||||
mse version: 0.3.7
|
||||
installer group: translations/Español
|
||||
full name: Español
|
||||
version: 2008-05-31
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
mse version: 0.3.7
|
||||
mse version: 0.3.7
|
||||
installer group: translations/Japanese
|
||||
full name: 日本語 (Japanese)
|
||||
version: 2008-06-25
|
||||
|
||||
@@ -25,6 +25,19 @@ DECLARE_TYPEOF(map<String COMMA SubLocaleP>);
|
||||
|
||||
// ----------------------------------------------------------------------------- : Locale class
|
||||
|
||||
// when reading, ignore "#_ADD" start of line pragmas
|
||||
|
||||
typedef void (*ReaderPragmaHandler)(String&);
|
||||
DECLARE_DYNAMIC_ARG(ReaderPragmaHandler,reader_pragma_handler);
|
||||
|
||||
void ignore_add_pragma(String& str) {
|
||||
if (starts_with(str,_("#_ADD "))) str = str.substr(6);
|
||||
else if (starts_with(str,_("#_ADD"))) str = str.substr(5);
|
||||
else if (starts_with(str,_("#_DEL"))) str.clear();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Locale class
|
||||
|
||||
LocaleP the_locale;
|
||||
|
||||
String Locale::typeName() const { return _("locale"); }
|
||||
@@ -36,6 +49,7 @@ LocaleP Locale::byName(const String& name) {
|
||||
|
||||
IMPLEMENT_REFLECTION_NO_SCRIPT(Locale) {
|
||||
REFLECT_BASE(Packaged);
|
||||
WITH_DYNAMIC_ARG(reader_pragma_handler, ignore_add_pragma);
|
||||
REFLECT_N("menu", translations[LOCALE_CAT_MENU]);
|
||||
REFLECT_N("help", translations[LOCALE_CAT_HELP]);
|
||||
REFLECT_N("tool", translations[LOCALE_CAT_TOOL]);
|
||||
|
||||
@@ -13,6 +13,10 @@
|
||||
#include <util/io/package_manager.hpp>
|
||||
#undef small
|
||||
|
||||
typedef void (*ReaderPragmaHandler)(String&);
|
||||
DECLARE_DYNAMIC_ARG (ReaderPragmaHandler,reader_pragma_handler);
|
||||
IMPLEMENT_DYNAMIC_ARG(ReaderPragmaHandler,reader_pragma_handler,nullptr);
|
||||
|
||||
// ----------------------------------------------------------------------------- : Reader
|
||||
|
||||
Reader::Reader(const InputStreamP& input, Packaged* package, const String& filename, bool ignore_invalid)
|
||||
@@ -225,18 +229,20 @@ void Reader::readLine(bool in_string) {
|
||||
} catch (const ParseError& e) {
|
||||
throw ParseError(e.what() + String(_(" on line ")) << line_number);
|
||||
}
|
||||
// pragma handler
|
||||
if (reader_pragma_handler()) reader_pragma_handler()(line);
|
||||
// read indentation
|
||||
indent = 0;
|
||||
while ((UInt)indent < line.size() && line.GetChar(indent) == _('\t')) {
|
||||
indent += 1;
|
||||
}
|
||||
// read key / value
|
||||
size_t pos = line.find_first_of(_(':'), indent);
|
||||
if (trim(line).empty() || line.GetChar(indent) == _('#')) {
|
||||
if (line.find_first_not_of(_(" \t")) == String::npos || line.GetChar(indent) == _('#')) {
|
||||
// empty line or comment
|
||||
key.clear();
|
||||
return;
|
||||
}
|
||||
size_t pos = line.find_first_of(_(':'), indent);
|
||||
key = line.substr(indent, pos - indent);
|
||||
if (!ignore_invalid && !in_string && starts_with(key, _(" "))) {
|
||||
warning(_("key: '") + key + _("' starts with a space; only use TABs for indentation!"), 0, false);
|
||||
|
||||
@@ -89,7 +89,10 @@ sub merge_locales {
|
||||
if ($what eq 'a') {
|
||||
# add
|
||||
for(my $k=0 ; $k < $len ; $pos_out++, $pos1++, $k++) {
|
||||
print "#_ADD", ($file1[$pos1] =~ /^\t/ ? '' : ' '), $file1[$pos1];
|
||||
my $line = $file1[$pos1];
|
||||
$line =~ s/^\xEF\xBB\xBF//; # eat BOM
|
||||
$line = "#_ADD" . ($line =~ /^\t/ ? '' : ' ') . $line;
|
||||
print $line;
|
||||
}
|
||||
} else {
|
||||
# delete
|
||||
|
||||
Reference in New Issue
Block a user