Re: Debian Wiki - macro like <> for translated pages?

2019-09-14 Thread Paul Wise
On Sat, Sep 14, 2019 at 9:42 PM Beatrice Torracca wrote:

> Perfect!! and with no work at all to do for translators *bg*

I learned to be lazy through automation early on :)

> On sabato 14 settembre 2019, at 19:41 +0800, Paul Wise wrote:
> > I found that macro.formatter.page.pi['language'] contains the language code.
>
> That happens when you know what you are doing :)

I had no idea beforehand, I just searched the builtin macro code for
'language' and eventually found a function that stores the page info
into the pi dictionary. OTOH, I did know Python before doing this :)

> Thanks a lot for this. Seems like a small detail maybe, but you made my day.

Glad I could help :)

-- 
bye,
pabs

https://wiki.debian.org/PaulWise



Re: Debian Wiki - macro like <> for translated pages?

2019-09-14 Thread Beatrice Torracca
On sabato 14 settembre 2019, at 19:41 +0800, Paul Wise wrote:
> On Sat, Sep 14, 2019 at 3:28 PM Beatrice Torracca  wrote:

> Thanks for the API pointer, with that and some grepping in the
> codebase I managed to add a few changes to make my proposal work:
> 
> https://salsa.debian.org/debian/wiki.debian.org/commit/80ae82957ae6cd4e19bbeae55e68908bb4971683
> 
> It is already working on the Italian translation of the DebianReleases
> page, it/DebianReleases links to it/DebianBuster but contains
> <>.

Perfect!! and with no work at all to do for translators *bg*

> > I did not find anything on a way to extract the iso-code of the language 
> > (that does not mean it does not exist).
> 
> I found that macro.formatter.page.pi['language'] contains the language code.

That happens when you know what you are doing :)

Thanks a lot for this. Seems like a small detail maybe, but you made my day.

beatrice



Re: Debian Wiki - macro like <> for translated pages?

2019-09-14 Thread Paul Wise
On Sat, Sep 14, 2019 at 3:28 PM Beatrice Torracca  wrote:

> There is a macro in the MoinMoin api to find if a page exist:

Thanks for the API pointer, with that and some grepping in the
codebase I managed to add a few changes to make my proposal work:

https://salsa.debian.org/debian/wiki.debian.org/commit/80ae82957ae6cd4e19bbeae55e68908bb4971683

It is already working on the Italian translation of the DebianReleases
page, it/DebianReleases links to it/DebianBuster but contains
<>.

> I did not find anything on a way to extract the iso-code of the language 
> (that does not mean it does not exist).

I found that macro.formatter.page.pi['language'] contains the language code.

--
bye,
pabs

https://wiki.debian.org/PaulWise



Re: Debian Wiki - macro like <> for translated pages?

2019-09-14 Thread Beatrice Torracca
On sabato 14 settembre 2019, at 07:56 +0800, Paul Wise wrote:
> On Sat, Sep 14, 2019 at 12:11 AM Beatrice Torracca wrote:

Hi,
> 
> > Is it possible to implement similar macros for the translated pages.
> 
> It should be possible to do that, the options are:
> 
> > Something along the line of <> where NN is 
> > the language code, at least for those languages which ask for it?
> * Add a language parameter: <>
> * Use the declared language of the page that is calling the macro when
> generating the links.
> 
> Personally I like the last option because it means almost zero work
> for translators, they just have to ensure the page language is
> declared correctly, which, from a small sample, appears to already be
> the case for probably many if not all of the translated pages.

Your idea is definitely better than mine

> 
> Would you be interested in working on this? If so, the Python code for
> Debian's custom macros is here:
> 
> https://salsa.debian.org/debian/wiki.debian.org/tree/master/var/moin/data/plugin/macro
> 
> If not I can take a look at how to find the current page language and
> how to detect if the translated page exists, it should be easy to fix
> the code once those are known.

Sadly I am no programmer. I have some very rudimentary skills that
make me tweak some previous code if it is easy to do. This is way
beyond my skills, sadly.

But I made some searches... with almost no useful results and probably
you know all this already :) ... but in case it might help whomever could
work on this these are the results.

There is a macro in the MoinMoing api to find if a page exist:

https://moinmo.in/MoinAPI/Examples#Page.exists.28.29

I did not find anything on a way to extract the iso-code of the language (that 
does not mean it does not exist). The only ugly workaround I could think of is 
to search in the raw content of the page for "# language NN".
But since there is the possibility of searching pages on the basis of their 
language there must be a better way to extract the language.

Thanks a lot for the reply,

beatrice



Re: Debian Wiki - macro like <> for translated pages?

2019-09-13 Thread Paul Wise
On Sat, Sep 14, 2019 at 12:11 AM Beatrice Torracca wrote:

> Is it possible to implement similar macros for the translated pages.

It should be possible to do that, the options are:

> Something along the line of <> where NN is 
> the language code, at least for those languages which ask for it?
* Add a language parameter: <>
* Use the declared language of the page that is calling the macro when
generating the links.

Personally I like the last option because it means almost zero work
for translators, they just have to ensure the page language is
declared correctly, which, from a small sample, appears to already be
the case for probably many if not all of the translated pages.

Would you be interested in working on this? If so, the Python code for
Debian's custom macros is here:

https://salsa.debian.org/debian/wiki.debian.org/tree/master/var/moin/data/plugin/macro

If not I can take a look at how to find the current page language and
how to detect if the translated page exists, it should be easy to fix
the code once those are known.

-- 
bye,
pabs

https://wiki.debian.org/PaulWise



Debian Wiki - macro like <> for translated pages?

2019-09-13 Thread Beatrice Torracca
Hi,

I have been meaning to ask this since a while ago.

Not too long ago macros like <>, 
<> have been implemented in the wiki. They get 
automatically replaced by the link to the correct page and thus the pages don't 
have to be manually corrected when there is a new release.

Sadly this is not true for the translated pages. So far I opted to use the 
original macro and readers can then chose to move to the translated page if 
they prefer. This way at least the link points to the correct Debian version.

Is it possible to implement similar macros for the translated pages. Something 
along the line of <> where NN is the language 
code, at least for those languages which ask for it?

BTW, I did try a couple of combinations similar to " 
it/<>", thinking that if the macro points to the 
page Stretch, that would point to it/Stretch, but that does not seem to work. 
Maybe I am doing something wrong and there is a way to do something like this 
instead of creating macros.

Thanks,

beatrice



--