Closed
Bug 731655
Opened 13 years ago
Closed 13 years ago
kumascript: Support localization in template content
Categories
(developer.mozilla.org Graveyard :: Editing, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: lorchard, Assigned: lorchard)
References
Details
(Whiteboard: u=user c=wiki s=2012-04-24 p=2)
This may not be kumascript-specific, but is at least feature parity with MindTouch.
In templates, there are HTML markup constructs like the following:
<span lang="en" class="lang lang-en">...</span>
<span lang="fr" class="lang lang-fr">...</span>
<span lang="pl" class="lang lang-pl">...</span>
<span lang="zh-cn" class="lang lang-zh-cn">...</span>
<span lang="*" class="lang lang-*">...</span>
When a template is rendered into a page, the only block that appears is the one that's appropriate for the page locale. This allows a single template to be localized in place, rather than split into per-locale templates.
We should support this, ideally with minimal changes to templates. The support might be more appropriately done on the Kuma/Python side than the kumascript/node side, though.
(In reply to Les Orchard [:lorchard] from comment #0)
> This may not be kumascript-specific, but is at least feature parity with
> MindTouch.
>
> In templates, there are HTML markup constructs like the following:
>
> <span lang="en" class="lang lang-en">...</span>
> <span lang="fr" class="lang lang-fr">...</span>
> <span lang="pl" class="lang lang-pl">...</span>
> <span lang="zh-cn" class="lang lang-zh-cn">...</span>
> <span lang="*" class="lang lang-*">...</span>
>
This type of template (span type) are templates that merged into a single Deki template from many locale MediaWiki templates.
Actually, these templates are replaced to new type template (switch type) like the following:
switch(lang) {
case 'fr':
// ...
break;
case 'pl':
// ...
break;
}
See an example:
https://developer.mozilla.org/index.php?title=Template:fx_minversion_header&action=diff&revision=18&diff=19
Additionally, for localizers, compared with per-locale templates, global templates (span type
and switch type) are difficult to control.
Localizers should control only own language, not other languages. If there are many languages in one templates, localizers have to control other languages, but this is difficult.
See an example, a De localizer edited other languages, but Ja localizer edited correctly:
https://developer.mozilla.org/index.php?title=Template:fx_minversion_header&action=diff&revision=24&diff=25
So, Kuma should adopt per-locale templates system (docs/<lang>/Template:) like SUMO, not global template system (docs/Template:) like Deki.
Comment 2•13 years ago
|
||
(In reply to Les Orchard [:lorchard] from comment #0)
> We should support this, ideally with minimal changes to templates. The
> support might be more appropriately done on the Kuma/Python side than the
> kumascript/node side, though.
What is the "minamal changes to templates"?
Assignee | ||
Comment 3•13 years ago
|
||
(In reply to potappo from comment #1)
> So, Kuma should adopt per-locale templates system (docs/<lang>/Template:)
> like SUMO, not global template system (docs/Template:) like Deki.
Actually, that might make things easier for us. What if it worked like this:
* Create a template at /en-US/docs/en-US/Template:HtmlElement
* Use it in an en-US page like /en-US/docs/en-US/SomePage
* Use it in a ja page like /en-US/docs/ja/SomeOtherPage
At first, the ja page will use the en-US template. But then...
* Create a template at /en-US/docs/ja/Template:HtmlElement
And now, the ja page will use the ja template instead.
So, then, templates will be single-locale and translated variants can be created like any other page.
The only problem is that this approach will require manual reworking / splitting up of templates that use the MindTouch language blocks in markup.
Comment 4•13 years ago
|
||
I don't like this idea for one reason: templates get updated pretty often, and this makes it more tricky to keep non-English templates up to date. If the change is just a styling thing, you can currently change one template and apply that change to all languages.
Assignee | ||
Comment 5•13 years ago
|
||
(In reply to Masahiko Imanaka [:marsf] from comment #2)
> (In reply to Les Orchard [:lorchard] from comment #0)
> > We should support this, ideally with minimal changes to templates. The
> > support might be more appropriately done on the Kuma/Python side than the
> > kumascript/node side, though.
>
> What is the "minamal changes to templates"?
I don't think I understand the question. Maybe this is the answer:
We're writing a new wiki, and it will have a new scripting system. There will be changes between MindTouch and the new Kuma wiki.
But, I'm trying to reduce the number of those changes as much possible. Because, many of those changes will require someone to manually edit templates and pages during the switch to the new wiki.
Comment 6•13 years ago
|
||
Kitsune templates have a neat trick involving the language of the page _including_ the template. I think if you did something like "{{untranslated-template}}" that included "<span style="something">{{translated-template}}</span>" and everyone translated the inner one, it would work.
Not 100% sure about that and it's probably wildly complicated to reimplement, just throwing it out there.
Assignee | ||
Comment 7•13 years ago
|
||
(In reply to Eric Shepherd [:sheppy] from comment #4)
> I don't like this idea for one reason: templates get updated pretty often,
> and this makes it more tricky to keep non-English templates up to date.
> If the change is just a styling thing, you can currently change one template
> and apply that change to all languages.
This is true. It would be easier to update a template all in one spot.
(In reply to Eric Shepherd [:sheppy] from comment #4)
> I don't like this idea for one reason: templates get updated pretty often,
> and this makes it more tricky to keep non-English templates up to date. If
> the change is just a styling thing, you can currently change one template
> and apply that change to all languages.
In this case, a template should be divided into style and message templates.
Then, a message template includes a style template. Though the method is depends on kumascript implement, this idea is same as comment #6.
Localizers would like to translate messages in templates, not style.
In English templates, you can make style templates to share other languages.
Assignee | ||
Updated•13 years ago
|
Summary: kumascript: Handle language alternate markup blocks → kumascript: Support localization in template content
Updated•13 years ago
|
Whiteboard: u=user c=wiki s=2012-04-24 p=
Comment 9•13 years ago
|
||
We need a page.lang property available to templates so we can do this:
switch(page.lang) {
case "de":
var note = "Hinweis:";
break;
case "es":
var note = "Nota:";
break;
...
}
<div class="note"><strong>web.html(note)</strong>(web.html(" " .. $0))</div>
Updated•13 years ago
|
Whiteboard: u=user c=wiki s=2012-04-24 p= → u=user c=wiki s=2012-04-24 p=2
Assignee | ||
Updated•13 years ago
|
Assignee: nobody → lorchard
Assignee | ||
Comment 10•13 years ago
|
||
I think I might have gone off the easily-PR-reviews rails with the bugfix-spree I'm doing for bug 730707. But, I think these commits fix this bug:
https://github.com/lmorchard/kumascript/commit/138db8e672412c9ba67e2d11178b39e6fe8eb815
https://github.com/lmorchard/kuma/commit/6b21b558cf08da7cc9af1ac5b372ebd29d3beddf
Assignee | ||
Comment 11•13 years ago
|
||
Actually, maybe these are easier commits to review. I just untangled them a bit from previous commits:
https://github.com/lmorchard/kumascript/commit/4f1ab85b14bc61fbd5bb128bd53dd43e03241265
https://github.com/lmorchard/kuma/commit/e72075ebe0398ecf6eccdbff0e9abd3a349b6937
Assignee | ||
Comment 12•13 years ago
|
||
An example template I reworked, using the new env.locale property:
http://mdn.lmorchard.com/en-US/docs/en-US/Template:XULRefElem
Assignee | ||
Comment 13•13 years ago
|
||
(Versus the original http://mdn.lmorchard.com/Template:XULRefElem )
Assignee | ||
Comment 14•13 years ago
|
||
Here's an example of what the new `env.locale` global allows:
http://mdn.lmorchard.com/en-US/docs/en-US/Template:XULRef
<%
var s = ["en-US/XUL", "en-US/XUL", "XUL Reference"];
switch (env.locale) {
case 'es': s = ["en/XUL", "en/XUL", "Referencia de XUL"]; break;
case 'de': s = ["en/XUL", "en/XUL", "XUL Referenz"]; break;
case 'ja': s = ["en/XUL", "en/XUL", "XUL リファレンス"]; break;
}
%>
« <a title="<%=s[0]%>" href="/docs/<%=s[1]%>"><%=s[2]%></a> «
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Updated•13 years ago
|
Version: MDN → unspecified
Updated•13 years ago
|
Component: Docs Platform → Editing
Updated•5 years ago
|
Product: developer.mozilla.org → developer.mozilla.org Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•