mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-22 14:54:43 +08:00
Still WIP
This commit is contained in:
@@ -1,44 +1,55 @@
|
||||
import Parsernostrum from "parsernostrum"
|
||||
import P from "parsernostrum"
|
||||
import Utility from "../Utility.js"
|
||||
import Grammar from "../serialization/Grammar.js"
|
||||
import AttributeInfo from "./AttributeInfo.js"
|
||||
import IEntity from "./IEntity.js"
|
||||
|
||||
export default class LocalizedTextEntity extends IEntity {
|
||||
|
||||
static attributes = {
|
||||
...super.attributes,
|
||||
namespace: AttributeInfo.createValue(""),
|
||||
key: AttributeInfo.createValue(""),
|
||||
value: AttributeInfo.createValue(""),
|
||||
lookbehind: new AttributeInfo({
|
||||
...super.attributes.lookbehind,
|
||||
default: "NSLOCTEXT",
|
||||
}),
|
||||
}
|
||||
static grammar = this.createGrammar()
|
||||
static lookbehind = "NSLOCTEXT"
|
||||
static grammar = P.regArray(new RegExp(
|
||||
String.raw`${this.attributes.lookbehind.default}\s*\(`
|
||||
+ String.raw`\s*"(${Grammar.Regex.InsideString.source})"\s*,`
|
||||
+ String.raw`\s*"(${Grammar.Regex.InsideString.source})"\s*,`
|
||||
+ String.raw`\s*"(${Grammar.Regex.InsideString.source})"\s*`
|
||||
+ String.raw`(?:,\s+)?`
|
||||
+ String.raw`\)`,
|
||||
"m"
|
||||
)).map(matchResult => new this(
|
||||
Utility.unescapeString(matchResult[1]),
|
||||
Utility.unescapeString(matchResult[2]),
|
||||
Utility.unescapeString(matchResult[3]),
|
||||
))
|
||||
|
||||
static createGrammar() {
|
||||
return Parsernostrum.regArray(new RegExp(
|
||||
String.raw`${this.attributes.lookbehind.default}\s*\(`
|
||||
+ String.raw`\s*"(${Grammar.Regex.InsideString.source})"\s*,`
|
||||
+ String.raw`\s*"(${Grammar.Regex.InsideString.source})"\s*,`
|
||||
+ String.raw`\s*"(${Grammar.Regex.InsideString.source})"\s*`
|
||||
+ String.raw`(?:,\s+)?`
|
||||
+ String.raw`\)`,
|
||||
"m"
|
||||
)).map(matchResult => new this({
|
||||
namespace: Utility.unescapeString(matchResult[1]),
|
||||
key: Utility.unescapeString(matchResult[2]),
|
||||
value: Utility.unescapeString(matchResult[3]),
|
||||
}))
|
||||
#namespace
|
||||
get namespace() {
|
||||
return this.#namespace
|
||||
}
|
||||
set namespace(value) {
|
||||
this.#namespace = value
|
||||
}
|
||||
|
||||
constructor(values) {
|
||||
super(values)
|
||||
/** @type {String} */ this.namespace
|
||||
/** @type {String} */ this.key
|
||||
/** @type {String} */ this.value
|
||||
#key
|
||||
get key() {
|
||||
return this.#key
|
||||
}
|
||||
set key(value) {
|
||||
this.#key = value
|
||||
}
|
||||
|
||||
#value
|
||||
get value() {
|
||||
return this.#value
|
||||
}
|
||||
set value(value) {
|
||||
this.#value = value
|
||||
}
|
||||
|
||||
|
||||
constructor(namespace = "", key = "", value = "") {
|
||||
super()
|
||||
this.namespace = namespace
|
||||
this.key = key
|
||||
this.value = value
|
||||
}
|
||||
|
||||
toString() {
|
||||
|
||||
Reference in New Issue
Block a user