The lang template function now accepts dynamic variables.
This commit is contained in:
parent
30de658e15
commit
dcd4d7d7eb
|
@ -1110,14 +1110,21 @@ ArgLoop:
|
||||||
if len(leftOperand) == 0 {
|
if len(leftOperand) == 0 {
|
||||||
panic("The left operand for the language string cannot be left blank")
|
panic("The left operand for the language string cannot be left blank")
|
||||||
}
|
}
|
||||||
if leftOperand[0] != '"' {
|
if leftOperand[0] == '"' {
|
||||||
panic("Phrase names cannot be dynamic")
|
// ! Slightly crude but it does the job
|
||||||
|
leftParam := strings.Replace(leftOperand, "\"", "", -1)
|
||||||
|
c.langIndexToName = append(c.langIndexToName, leftParam)
|
||||||
|
notident = true
|
||||||
|
con.PushPhrase(len(c.langIndexToName) - 1)
|
||||||
|
} else {
|
||||||
|
leftParam := leftOperand
|
||||||
|
if leftOperand[0] != '"' {
|
||||||
|
leftParam, _ = c.compileIfVarSub(con, leftParam)
|
||||||
|
}
|
||||||
|
// TODO: Add an optimisation if it's a string literal passsed in from a parent template rather than a true dynamic
|
||||||
|
litString("phrases.GetTmplPhrasef("+leftParam+")", false)
|
||||||
|
c.importMap[langPkg] = langPkg
|
||||||
}
|
}
|
||||||
// ! Slightly crude but it does the job
|
|
||||||
leftParam := strings.Replace(leftOperand, "\"", "", -1)
|
|
||||||
c.langIndexToName = append(c.langIndexToName, leftParam)
|
|
||||||
notident = true
|
|
||||||
con.PushPhrase(len(c.langIndexToName) - 1)
|
|
||||||
break ArgLoop
|
break ArgLoop
|
||||||
case "langf":
|
case "langf":
|
||||||
// TODO: Implement string literals properly
|
// TODO: Implement string literals properly
|
||||||
|
|
Loading…
Reference in New Issue