mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Rename message content 'str' key to 'text'
This commit is contained in:
@@ -356,8 +356,8 @@ display: 'OBSE v18+'
|
||||
<table>
|
||||
<thead><tr><th>Key Name<th>Required<th>Notes
|
||||
<tbody>
|
||||
<tr><td><code>str</code><td>✓<td>The actual message content string.
|
||||
<tr><td><code>lang</code><td>✓<td>The language that <code>str</code> is written in, given as a POSIX language code. The languages LOOT supports are given in <a href="#lang">Language Codes</a>.
|
||||
<tr><td><code>text</code><td>✓<td>The actual message content string.
|
||||
<tr><td><code>lang</code><td>✓<td>The language that <code>text</code> is written in, given as a POSIX language code. The languages LOOT supports are given in <a href="#lang">Language Codes</a>.
|
||||
</table>
|
||||
|
||||
<h4>Equality</h4>
|
||||
@@ -373,9 +373,9 @@ display: 'OBSE v18+'
|
||||
condition: 'file("foo.esp")'
|
||||
content:
|
||||
- lang: en
|
||||
str: 'An example link: <http://www.example.com>'
|
||||
text: 'An example link: <http://www.example.com>'
|
||||
- lang: ru
|
||||
str: 'Это пример ссылки: <http://www.example.com>'
|
||||
text: 'Это пример ссылки: <http://www.example.com>'
|
||||
</code></pre>
|
||||
would be displayed as
|
||||
<blockquote>
|
||||
|
||||
@@ -56,7 +56,7 @@ Emitter& operator << (Emitter& out, const loot::MessageContent& rhs) {
|
||||
|
||||
out << Key << "lang" << Value << loot::Language(rhs.GetLanguage()).GetLocale();
|
||||
|
||||
out << Key << "str" << Value << YAML::SingleQuoted << rhs.GetText();
|
||||
out << Key << "text" << Value << YAML::SingleQuoted << rhs.GetText();
|
||||
|
||||
out << EndMap;
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ template<>
|
||||
struct convert<loot::MessageContent> {
|
||||
static Node encode(const loot::MessageContent& rhs) {
|
||||
Node node;
|
||||
node["str"] = rhs.GetText();
|
||||
node["text"] = rhs.GetText();
|
||||
node["lang"] = loot::Language(rhs.GetLanguage()).GetLocale();
|
||||
|
||||
return node;
|
||||
@@ -61,15 +61,15 @@ struct convert<loot::MessageContent> {
|
||||
static bool decode(const Node& node, loot::MessageContent& rhs) {
|
||||
if (!node.IsMap())
|
||||
throw RepresentationException(node.Mark(), "bad conversion: 'message content' object must be a map");
|
||||
if (!node["str"])
|
||||
throw RepresentationException(node.Mark(), "bad conversion: 'str' key missing from 'message content' object");
|
||||
if (!node["text"])
|
||||
throw RepresentationException(node.Mark(), "bad conversion: 'text' key missing from 'message content' object");
|
||||
if (!node["lang"])
|
||||
throw RepresentationException(node.Mark(), "bad conversion: 'lang' key missing from 'message content' object");
|
||||
|
||||
std::string str = node["str"].as<std::string>();
|
||||
std::string text = node["text"].as<std::string>();
|
||||
loot::Language::Code lang = loot::Language(node["lang"].as<std::string>()).GetCode();
|
||||
|
||||
rhs = loot::MessageContent(str, lang);
|
||||
rhs = loot::MessageContent(text, lang);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -267,7 +267,7 @@ loot-editor-close
|
||||
return {
|
||||
type: rowData.type,
|
||||
content: [{
|
||||
str: rowData.content,
|
||||
text: rowData.content,
|
||||
lang: rowData.language,
|
||||
}],
|
||||
condition: rowData.condition,
|
||||
@@ -362,7 +362,7 @@ loot-editor-close
|
||||
_messageToRowData(message) {
|
||||
return {
|
||||
type: message.type,
|
||||
content: message.content[0].str,
|
||||
content: message.content[0].text,
|
||||
condition: message.condition,
|
||||
language: message.content[0].lang,
|
||||
};
|
||||
|
||||
@@ -121,8 +121,8 @@ function onSortPlugins() {
|
||||
|
||||
if (!result.plugins) {
|
||||
const message = result.globalMessages.find(item => (
|
||||
item.content[0].str.startsWith('Cyclic interaction detected'
|
||||
))).content[0].str;
|
||||
item.content[0].text.startsWith('Cyclic interaction detected'
|
||||
))).content[0].text;
|
||||
throw new Error(loot.l10n.translate(`Failed to sort plugins. Details: ${message}`));
|
||||
}
|
||||
|
||||
|
||||
@@ -260,7 +260,7 @@
|
||||
if (this.globalMessages) {
|
||||
messages = this.globalMessages.map(message => ({
|
||||
type: message.type,
|
||||
content: message.content[0].str,
|
||||
content: message.content[0].text,
|
||||
}));
|
||||
}
|
||||
if (this.plugins) {
|
||||
@@ -379,7 +379,7 @@
|
||||
const li = document.createElement('li');
|
||||
li.className = message.type;
|
||||
/* Use the Marked library for Markdown formatting support. */
|
||||
li.innerHTML = marked(message.content[0].str);
|
||||
li.innerHTML = marked(message.content[0].text);
|
||||
generalMessagesList.appendChild(li);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
|
||||
this._messages = plugin.messages.map(message => ({
|
||||
type: message.type,
|
||||
content: message.content[0].str,
|
||||
content: message.content[0].text,
|
||||
})).filter(filters.messageFilter, filters);
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ TEST(MessageContent, emittingAsYamlShouldOutputDataCorrectly) {
|
||||
emitter << content;
|
||||
|
||||
EXPECT_EQ("lang: " + Language(content.GetLanguage()).GetLocale() +
|
||||
"\nstr: '" + content.GetText() + "'", emitter.c_str());
|
||||
"\ntext: '" + content.GetText() + "'", emitter.c_str());
|
||||
}
|
||||
|
||||
TEST(MessageContent, encodingAsYamlShouldOutputDataCorrectly) {
|
||||
@@ -87,12 +87,12 @@ TEST(MessageContent, encodingAsYamlShouldOutputDataCorrectly) {
|
||||
YAML::Node node;
|
||||
node = content;
|
||||
|
||||
EXPECT_EQ(content.GetText(), node["str"].as<std::string>());
|
||||
EXPECT_EQ(content.GetText(), node["text"].as<std::string>());
|
||||
EXPECT_EQ(Language(Language::Code::french).GetLocale(), node["lang"].as<std::string>());
|
||||
}
|
||||
|
||||
TEST(MessageContent, decodingFromYamlShouldSetDataCorrectly) {
|
||||
YAML::Node node = YAML::Load("{str: content, lang: de}");
|
||||
YAML::Node node = YAML::Load("{text: content, lang: de}");
|
||||
MessageContent content = node.as<MessageContent>();
|
||||
|
||||
EXPECT_EQ("content", content.GetText());
|
||||
|
||||
@@ -212,9 +212,9 @@ TEST_P(MessageTest, emittingAsYamlShouldOutputMultipleContentStringsAsAList) {
|
||||
EXPECT_STREQ("type: say\n"
|
||||
"content:\n"
|
||||
" - lang: en\n"
|
||||
" str: 'content1'\n"
|
||||
" text: 'content1'\n"
|
||||
" - lang: de\n"
|
||||
" str: 'content2'", emitter.c_str());
|
||||
" text: 'content2'", emitter.c_str());
|
||||
}
|
||||
|
||||
TEST_P(MessageTest, encodingAsYamlShouldStoreNoteMessageTypeCorrectly) {
|
||||
@@ -339,9 +339,9 @@ TEST_P(MessageTest, decodingFromYamlShouldStoreAListOfContentStringsCorrectly) {
|
||||
YAML::Node node = YAML::Load("type: say\n"
|
||||
"content:\n"
|
||||
" - lang: en\n"
|
||||
" str: content1\n"
|
||||
" text: content1\n"
|
||||
" - lang: de\n"
|
||||
" str: content2");
|
||||
" text: content2");
|
||||
Message message = node.as<Message>();
|
||||
|
||||
EXPECT_EQ(MessageContents({
|
||||
@@ -354,7 +354,7 @@ TEST_P(MessageTest, decodingFromYamlShouldNotThrowIfTheOnlyContentStringIsNotEng
|
||||
YAML::Node node = YAML::Load("type: say\n"
|
||||
"content:\n"
|
||||
" - lang: fr\n"
|
||||
" str: content1");
|
||||
" text: content1");
|
||||
|
||||
EXPECT_NO_THROW(Message message = node.as<Message>());
|
||||
}
|
||||
@@ -363,9 +363,9 @@ TEST_P(MessageTest, decodingFromYamlShouldThrowIfMultipleContentStringsAreGivenA
|
||||
YAML::Node node = YAML::Load("type: say\n"
|
||||
"content:\n"
|
||||
" - lang: de\n"
|
||||
" str: content1\n"
|
||||
" text: content1\n"
|
||||
" - lang: fr\n"
|
||||
" str: content2");
|
||||
" text: content2");
|
||||
|
||||
EXPECT_THROW(node.as<Message>(), YAML::RepresentationException);
|
||||
}
|
||||
@@ -384,9 +384,9 @@ TEST_P(MessageTest, decodingFromYamlShouldApplySubstitutionsToAllContentStrings)
|
||||
YAML::Node node = YAML::Load("type: say\n"
|
||||
"content:\n"
|
||||
" - lang: en\n"
|
||||
" str: content1 %1%\n"
|
||||
" text: content1 %1%\n"
|
||||
" - lang: de\n"
|
||||
" str: content2 %1%\n"
|
||||
" text: content2 %1%\n"
|
||||
"subs:\n"
|
||||
" - sub");
|
||||
Message message = node.as<Message>();
|
||||
|
||||
@@ -60,12 +60,12 @@
|
||||
messages: [{
|
||||
type: 'say',
|
||||
content: [{
|
||||
str: 'This is a *test* note.',
|
||||
text: 'This is a *test* note.',
|
||||
}],
|
||||
}, {
|
||||
type: 'warn',
|
||||
content: [{
|
||||
str: 'This is a **test** warning.',
|
||||
text: 'This is a **test** warning.',
|
||||
}],
|
||||
}],
|
||||
}),
|
||||
|
||||
@@ -379,7 +379,7 @@ describe('Game', () => {
|
||||
condition: 'file("foo.esp")',
|
||||
content: [{
|
||||
lang: 'fr',
|
||||
str: 'Bonjour le monde',
|
||||
text: 'Bonjour le monde',
|
||||
}],
|
||||
}];
|
||||
game._plugins = [{
|
||||
@@ -400,7 +400,7 @@ describe('Game', () => {
|
||||
condition: 'file("bar.esp")',
|
||||
content: [{
|
||||
lang: 'en',
|
||||
str: 'Hello world',
|
||||
text: 'Hello world',
|
||||
}],
|
||||
}],
|
||||
tags: ['invalidStructure'],
|
||||
@@ -414,7 +414,7 @@ describe('Game', () => {
|
||||
game.getContent().should.deepEqual({
|
||||
messages: [{
|
||||
type: game._globalMessages[0].type,
|
||||
content: game._globalMessages[0].content[0].str,
|
||||
content: game._globalMessages[0].content[0].text,
|
||||
}],
|
||||
plugins: [{
|
||||
name: game._plugins[0].name,
|
||||
|
||||
@@ -1087,14 +1087,14 @@ describe('PluginCardContent', () => {
|
||||
{
|
||||
type: 'say',
|
||||
content: [{
|
||||
str: 'test message',
|
||||
text: 'test message',
|
||||
lang: 'en',
|
||||
}],
|
||||
},
|
||||
{
|
||||
type: 'warn',
|
||||
content: [{
|
||||
str: 'do not clean',
|
||||
text: 'do not clean',
|
||||
lang: 'en',
|
||||
}],
|
||||
},
|
||||
@@ -1270,11 +1270,11 @@ describe('PluginCardContent', () => {
|
||||
plugin.getCardContent(filters).messages.should.deepEqual([
|
||||
{
|
||||
type: plugin.messages[0].type,
|
||||
content: plugin.messages[0].content[0].str,
|
||||
content: plugin.messages[0].content[0].text,
|
||||
},
|
||||
{
|
||||
type: plugin.messages[1].type,
|
||||
content: plugin.messages[1].content[0].str,
|
||||
content: plugin.messages[1].content[0].text,
|
||||
},
|
||||
]);
|
||||
});
|
||||
@@ -1283,7 +1283,7 @@ describe('PluginCardContent', () => {
|
||||
filters.hideNotes = true;
|
||||
plugin.getCardContent(filters).messages.should.deepEqual([{
|
||||
type: plugin.messages[1].type,
|
||||
content: plugin.messages[1].content[0].str,
|
||||
content: plugin.messages[1].content[0].text,
|
||||
}]);
|
||||
});
|
||||
|
||||
@@ -1291,7 +1291,7 @@ describe('PluginCardContent', () => {
|
||||
filters.hideDoNotCleanMessages = true;
|
||||
plugin.getCardContent(filters).messages.should.deepEqual([{
|
||||
type: plugin.messages[0].type,
|
||||
content: plugin.messages[0].content[0].str,
|
||||
content: plugin.messages[0].content[0].text,
|
||||
}]);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user