mirror of
https://github.com/Reuh/anselme.git
synced 2025-10-28 00:59:31 +00:00
Translation system first draft
This commit is contained in:
parent
ffadc0dd69
commit
c4636343b4
15 changed files with 215 additions and 18 deletions
|
|
@ -28,6 +28,7 @@ local primaries = {
|
|||
r("prefix.negation"),
|
||||
r("prefix.not"),
|
||||
r("prefix.mutable"),
|
||||
r("prefix.translatable"),
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
|||
16
parser/expression/primary/prefix/translatable.lua
Normal file
16
parser/expression/primary/prefix/translatable.lua
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
local prefix = require("parser.expression.primary.prefix.prefix")
|
||||
|
||||
local ast = require("ast")
|
||||
local Translatable = ast.Translatable
|
||||
|
||||
local operator_priority = require("common").operator_priority
|
||||
|
||||
return prefix {
|
||||
operator = "%",
|
||||
identifier = "%_",
|
||||
priority = operator_priority["%_"],
|
||||
|
||||
build_ast = function(self, right)
|
||||
return Translatable:new(right)
|
||||
end
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
local string = require("parser.expression.primary.string")
|
||||
|
||||
local ast = require("ast")
|
||||
local TextInterpolation = ast.TextInterpolation
|
||||
local TextInterpolation, Translatable = ast.TextInterpolation, ast.Translatable
|
||||
|
||||
return string {
|
||||
type = "text",
|
||||
|
|
@ -11,6 +11,7 @@ return string {
|
|||
interpolation = TextInterpolation,
|
||||
|
||||
parse = function(self, source, str, limit_pattern)
|
||||
local start_source = source:clone()
|
||||
local interpolation, rem = string.parse(self, source, str, limit_pattern)
|
||||
|
||||
-- restore | when chaining with a choice operator
|
||||
|
|
@ -19,6 +20,6 @@ return string {
|
|||
source:increment(-1)
|
||||
end
|
||||
|
||||
return interpolation, rem
|
||||
return Translatable:new(interpolation):set_source(start_source), rem
|
||||
end
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue