langf now works in transpiled templates, albeit a little inefficiently.
Removed the quick_topic.add_poll_option phrase. Added the quick_topic.add_poll_option_first phrase. Changed the topic.reply_add_poll_option phrase. Added the topic.reply_add_poll_option_first phrase.
This commit is contained in:
parent
89c8f4e775
commit
89ca5ee823
|
@ -179,6 +179,7 @@ type TopicCAttachItem struct {
|
|||
}
|
||||
type TopicCPollInput struct {
|
||||
Index int
|
||||
Place string
|
||||
}
|
||||
|
||||
type TopicPage struct {
|
||||
|
|
|
@ -49,6 +49,11 @@ func (con *CContext) PushPhrase(langIndex int) (index int) {
|
|||
return con.LastBufIndex()
|
||||
}
|
||||
|
||||
func (con *CContext) PushPhrasef(langIndex int, args string) (index int) {
|
||||
*con.OutBuf = append(*con.OutBuf, OutBufferFrame{args, "langf", con.TemplateName, langIndex, nil})
|
||||
return con.LastBufIndex()
|
||||
}
|
||||
|
||||
func (con *CContext) StartLoop(body string) (index int) {
|
||||
con.LoopDepth++
|
||||
return con.Push("startloop", body)
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
"runtime/debug"
|
||||
"strconv"
|
||||
"strings"
|
||||
"unicode"
|
||||
"text/template/parse"
|
||||
"time"
|
||||
)
|
||||
|
@ -106,7 +107,7 @@ func NewCTemplateSet(in string) *CTemplateSet {
|
|||
"hasWidgets": true,
|
||||
"elapsed": true,
|
||||
"lang": true,
|
||||
//"langf":true,
|
||||
"langf":true,
|
||||
"level": true,
|
||||
"bunit": true,
|
||||
"abstime": true,
|
||||
|
@ -1109,7 +1110,56 @@ ArgLoop:
|
|||
notident = true
|
||||
con.PushPhrase(len(c.langIndexToName) - 1)
|
||||
break ArgLoop
|
||||
// TODO: Implement langf
|
||||
case "langf":
|
||||
// TODO: Implement string literals properly
|
||||
leftOperand := node.Args[pos+1].String()
|
||||
if len(leftOperand) == 0 {
|
||||
panic("The left operand for the language string cannot be left blank")
|
||||
}
|
||||
if leftOperand[0] != '"' {
|
||||
panic("Phrase names cannot be dynamic")
|
||||
}
|
||||
|
||||
var olist []string
|
||||
for i := pos+2; i < len(node.Args); i++ {
|
||||
op := node.Args[i].String()
|
||||
if op != "" {
|
||||
if op[0] == '.' || op[0] == '$' {
|
||||
panic("langf args cannot be dynamic")
|
||||
}
|
||||
if op[0] != '"' && !unicode.IsDigit(rune(op[0])) {
|
||||
break
|
||||
}
|
||||
olist = append(olist,op)
|
||||
}
|
||||
}
|
||||
if len(olist) == 0 {
|
||||
panic("You must provide parameters for langf")
|
||||
}
|
||||
|
||||
var ob = ","
|
||||
for _, op := range olist {
|
||||
allNum := true
|
||||
for _, o := range op {
|
||||
if !unicode.IsDigit(o) {
|
||||
allNum = false
|
||||
}
|
||||
}
|
||||
if allNum {
|
||||
ob += strings.Replace(op,"\"","\\\"",-1) + ","
|
||||
} else {
|
||||
ob += ob + ","
|
||||
}
|
||||
}
|
||||
if ob != "" {
|
||||
ob = ob[:len(ob)-1]
|
||||
}
|
||||
|
||||
// TODO: Implement string literals properly
|
||||
// ! Slightly crude but it does the job
|
||||
litString("phrases.GetTmplPhrasef("+leftOperand+ob+")", false)
|
||||
c.importMap[langPkg] = langPkg
|
||||
break ArgLoop
|
||||
case "level":
|
||||
// TODO: Implement level literals
|
||||
leftOperand := node.Args[pos+1].String()
|
||||
|
|
|
@ -546,7 +546,7 @@
|
|||
"quick_topic.avatar_alt":"Your Avatar",
|
||||
"quick_topic.whatsup":"What's up?",
|
||||
"quick_topic.content_placeholder":"Insert post here",
|
||||
"quick_topic.add_poll_option":"Poll option",
|
||||
"quick_topic.add_poll_option_first":"Poll option #0",
|
||||
"quick_topic.create_topic_button":"Create Topic",
|
||||
"quick_topic.create_topic_button_short":"New Topic",
|
||||
"quick_topic.add_poll_button":"Add Poll",
|
||||
|
@ -653,7 +653,8 @@
|
|||
"topic.reply_aria":"The quick reply form",
|
||||
"topic.reply_content":"Insert reply here",
|
||||
"topic.reply_content_alt":"What do you think?",
|
||||
"topic.reply_add_poll_option":"Poll option",
|
||||
"topic.reply_add_poll_option":"Poll option #%d",
|
||||
"topic.reply_add_poll_option_first":"Poll option #0",
|
||||
"topic.reply_button":"Create Reply",
|
||||
"topic.reply_add_poll_button":"Add Poll",
|
||||
"topic.reply_add_file_button":"Add File",
|
||||
|
|
|
@ -286,6 +286,7 @@
|
|||
if(dataPollInput != (pollInputIndex-1)) return;
|
||||
$(".poll_content_row .formitem").append(Template_topic_c_poll_input({
|
||||
Index: pollInputIndex,
|
||||
Place: phraseBox["topic"]["topic.reply_add_poll_option"].replace("%d",pollInputIndex),
|
||||
}));
|
||||
pollInputIndex++;
|
||||
console.log("new pollInputIndex: ", pollInputIndex);
|
||||
|
|
|
@ -82,10 +82,10 @@
|
|||
</div>
|
||||
<div class="formrow poll_content_row auto_hide">
|
||||
<div class="formitem">
|
||||
<div class="pollinput" data-pollinput="0">
|
||||
<div class="pollinput" data-pollinput=0>
|
||||
<input type="checkbox" disabled />
|
||||
<label class="pollinputlabel"></label>
|
||||
<input form="quick_post_form" name="pollinputitem[0]" class="pollinputinput" type="text" placeholder="{{lang "topic.reply_add_poll_option"}}" />
|
||||
<input form="quick_post_form" name="pollinputitem[0]" class="pollinputinput" type="text" placeholder="{{lang "topic.reply_add_poll_option_first"}}" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -17,10 +17,10 @@
|
|||
</div>
|
||||
<div class="formrow poll_content_row auto_hide">
|
||||
<div class="formitem">
|
||||
<div class="pollinput" data-pollinput="0">
|
||||
<div class="pollinput" data-pollinput=0>
|
||||
<input type="checkbox" disabled />
|
||||
<label class="pollinputlabel"></label>
|
||||
<input form="quick_post_form" name="pollinputitem[0]" class="pollinputinput" type="text" placeholder="{{lang "topic.reply_add_poll_option"}}" />
|
||||
<input form="quick_post_form" name="pollinputitem[0]" class="pollinputinput" type="text" placeholder="{{lang "topic.reply_add_poll_option_first"}}" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<div class='pollinput' data-pollinput='{{.Index}}'>
|
||||
<div class='pollinput' data-pollinput={{.Index}}>
|
||||
<input type='checkbox' disabled />
|
||||
<label class='pollinputlabel'></label>
|
||||
<input form='quick_post_form' name='pollinputitem[{{.Index}}]' class='pollinputinput' type='text' placeholder='{{lang "topic.reply_add_poll_option"}}' />
|
||||
<input form='quick_post_form' name='pollinputitem[{{.Index}}]' class='pollinputinput' type='text' placeholder='{{.Place}}' />
|
||||
</div>
|
|
@ -6,10 +6,10 @@
|
|||
</div>
|
||||
<div class="formrow poll_content_row auto_hide">
|
||||
<div class="formitem">
|
||||
<div class="pollinput" data-pollinput="0">
|
||||
<div class="pollinput" data-pollinput=0>
|
||||
<input type="checkbox" disabled />
|
||||
<label class="pollinputlabel"></label>
|
||||
<input form="quick_post_form" name="pollinputitem[0]" class="pollinputinput" type="text" placeholder="{{lang "quick_topic.add_poll_option"}}" />
|
||||
<input form="quick_post_form" name="pollinputitem[0]" class="pollinputinput" type="text" placeholder="{{lang "quick_topic.add_poll_option_first"}}" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue