acrylamid
acrylamid copied to clipboard
'tagged as' and 'and' could be localizated in theme/entry.html
Just a minor bug: in theme/entry.html subsitute 'tagged as' and 'and' with localizated version:
% if 'tag' in env.views and entry.tags:
<p>tagged as
% for link in tagify(entry.tags):
<a href="${ env.path + link.href }" rel="tag">${ link.title }</a>
% if loop.reverse_index > 1:
,
% elif loop.reverse_index == 1:
i
% endif
% endfor
</p>
% elif not entry.draft:
<p>untagged</p>
% endif
Same with 'written by {{author}}' and in articles page title.
How can I manually put a localizated string? That is if 'foo' is a string, how can I localizated 'foo'? Is there any function like 'localizate('foo')' that simply reads the locale and read the translation of 'foo'?
Hi @xavimat unfortunately not. I do plan to add a function like i18n('bar')
in the next release (using some default translations from the Nikola project).
I18n templates has been on my todo list for several months now :(
@posativ, a pain, really pain. Please set is as priority bug ;-)
Hi @xavimat, can you give me some hints on the expected usage? Do you use the translation view?
@posativ: Translation view? What is this?
My expected usage is to "translate" the template theme/entry.html. For example, in that file, there is a string:
'written by {{author}}'
This is not localized. I want to have "i18n('written by {0}'.format({{author}}) for display this message depending of LANG appeared in conf.py. So if the page has translation to several languages, the users see localizated message...
If not, manual intervention is required if lang==foo, then ....
By the other hand, don't forget to right-to-left languages.
'continue' in index.html nope.
You can set SUMMARIZE_LINK to a custom value.
Thanks
But I receive error:
Traceback (most recent call last):
File "/usr/lib/python3.3/site-packages/pkg_resources.py", line 2822, in
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/xan//.local/bin/acrylamid", line 5, in
Because, I recently updated Jinja
Yep. Jinja 2.7 does not work with Acrylamid anyways. Either use the master (of both Jinja2 and Acrylamid, I do not recomend that) or stay with Jinja 2.6 (ported by hand btw).
I reinstall jinja2.6 but I get now this issue:
xan@gerret:/home/xan/proves/github/[email protected]/cepasud$ acrylamid co
Traceback (most recent call last):
File "/home/xan//.local/bin/acrylamid", line 9, in
Please refer to the documentation: http://posativ.org/acrylamid/filters.html#summarize :
[...] This string must contain %s where the link location will be inserted.
OK.
Hi @xavimat, I experimented a bit with i18n support in templates and that's my progress so far:
- [x] imported nikola's i18n messages
- [x] Jinja2's i18n extensions works fine when you write
{% trans %}Archive{% endtrans %}
in your templates and your conf.py saysLANG = 'es'
for example. - [x] translated posts currently use post's language
- [ ] support for custom messages not included, e.g. "tagged as" is not available in Nikola.
OK. Thanks for the improvements. By now, I will not updated acrylamid, but in the future, I will...
I18N support is nearly finished, but I have no idea for the last missing point: custom messages. There's probably no option to use custom messages (unless you write the .po, compile to .mo and then merge both catalogs).
Another option would be a custom implementation of the gettext
interface to provide easier integration of custom messages, such as:
# $ cat messages/custom.py
["english text", "spanish text", [optional third etc.],
["next text", ...]
whereas per convention the first item per list is the default language (or english?). Because I don't like the repetition of something like:
# messages/de.py
{
"Hello": "Hallo",
"World": "Welt"
}
# messages/es.py
{
"Hello": "Hola",
"World": "Mundo"
}
So, what do you prefer?
Why not {"Hello": {'en': 'Hello', 'es': 'Hola', ...}, "Bye": {'en': 'Bye', 'es': 'Adiós', ...}}?
``Yes, a good idea... could be used as a fallback to a preset of messages. So, I'm fine with custom messages in the conf.py via:
MESSAGES = {
"Hello": {"en": "Hello", "es": "Hola"},
...
}
EDIT: there's probably no need for "Hello": {"en": "Hello"}
(provide a "translation" for the english identifier) ... but only "Hello": {"es": "Hola"}
.
Proud if you think it's good idea. I include "Hello": {"en": "Hello"} plus DEFAULT_LANG='en' (or whatever). Please, think not all content is english centric.