[mlz] default locale not working with twlaw after 4.0.14m420 update
As titled. When trying to cite (in Word) an item of which the language field is left blank, I would get an error message that says:
No output when tested in the CSL Editor pane or the CSL Preview pane.
No problem if I put "en" (or "zh" for that matter) in the language field. No problem either if set to use the almlaw style.Zotero experienced an error updating your document.
this.locale[lang] is undefined
No output when tested in the CSL Editor pane or the CSL Preview pane.
There were a number of problems in the application of locales. I've tested the obvious problem cases (invalid locales and alternative region codes set in the item language field), and I'm pretty confident it will work reliably for you now.
Note that the default locale for "zh" is "zh-CH" in CSL. You can specify multiple locales on a layout. The layout will match any of the listed locales, and the first-listed locale will be applied when rendering terms.
Following that logic, to apply the zh-TW locale to all Chinese items, you should set the in-style locale definition to "zh-TW", and set the layout locales as "zh-TW zh". That should yield the "zh-TW" locale for all items that have "zh" as their base language code. Invalid item language codes and items with no language code should fall back to the style default.
I will need to wade into the logic for selecting sort-key locales again -- it currently falls back gracefully to the base locale of the item automatically, while the layout locales just fail to the style default. On reflection, I think the latter behaviour may be better (because explicit is better than implicit). Not sure though.
In any case, at some point I will have to bring the sort locale selection logic and the layout locale selection logic into line with one another. For now, though, the settings described above should get things working.
(Edited to show my current uncertainty over the correct locale selection behaviour.)
With the new settings:
<style ... default-locale-sort="zh-TW">
...
<locale xml:lang="zh-TW">
...
<citation ...>
<layout locale="zh-TW zh" delimiter=";" suffix="。">
tw_layout_codes...
an item will be formatted according to "tw_layout_codes" if its language is set to "zh", "zh-TW", "zh-CH" or any other "zh" variant, right? I guess that's to be expected before a new layout section is in place for another zh locale.
Under my old settings:
<style ... default-locale-sort="zh-TW">
...
<locale xml:lang="zh">
...
<citation ...>
<layout locale="zh" delimiter=";" suffix="。">
tw_layout_codes...
the result should be the same, isn't it?
I guess I don't really get yet how the default locale works for a given language. I thought it would makes a difference only when both
<layout locale="zh-TW" ...>
and<layout locale="zh-CH" ...>
were defined, and neither claimed to be the default for "zh" by including "zh" in the "locale=" setting. An item whose language code is set to only "zh" should be formatted according to the "zh-CH" layout, for it's the default locale for zh.What am I missing here? Maybe I'll test it out tomorrow. Anyway, thank you for the speedy fix.
With the old settings, an item set explicitly to "zh-TW" would (or should) render in the default locale (i.e. en-US), because it is not a strict match for the locale specified in the layout ("zh-CH" after resolution).
No changes are needed to mlz-twlaw.csl for the new code, but it will now work better with layouts that require (say) matching a set of language variants that require Latin characters, before falling back to Cyrillic for the main language. Or vice-versa etc.
The changes have been tested, but if you do run into problems give me a shout.