Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2021-02-09 14:47:33

Kjeld
Member
From: Tokyo, Japan
Registered: 2005-02-05
Posts: 285
Website

Re: Challenging upgrade and redesign issues 😳

Once again, thank you all for thinking with me on this one and for the suggestions. I really appreciate it.

If I understand all the suggestions correctly, they are for translations of the articles only and not the categories and the rest of the site?


JapaneseStreets.com – Japanese street fashion (mostly txp)
Old Photos of Japan – Japan between 1860 and 1940 (100% txp)
MeijiShowa – Stock photos of Japan between 1860 and 1940 (100% txp)

Offline

#14 2021-02-09 14:48:53

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,087
Website

Re: Challenging upgrade and redesign issues 😳

Kjeld wrote #328673:

MLP inserts the language markers, but otherwise leaves the URLs alone, I believe.

My mini-plugin does the same. It strips off the first part of the url if it matches one of the permitted language codes and passes on the rest of the URL for Textpattern to handle as normal. If an incorrect language code is input it defaults to a standard lang code. There’s a tag to output the lang code.

I have already used up all my custom fields on this site… I guess I could use glz_custom_fields if it still works with the latest txp version

glz_custom_fields in the v2 still works on the latest txp version :-)


TXP Builders – finely-crafted code, design and txp

Offline

#15 2021-02-09 14:54:46

Kjeld
Member
From: Tokyo, Japan
Registered: 2005-02-05
Posts: 285
Website

Re: Challenging upgrade and redesign issues 😳

jakob wrote #328674:

I’m sure I can explain it better if you have more detailed questions. And it may not all be necessary depending on how you have your site setup and how much of MLP you were using.

Given your extensive image catalog and the need to keep article + image IDs intact, you may find that some careful manual offsite preparation of the images and the corresponding txp_image table may be much quicker than re-uploading and making things match. It feels a bit messy and requires working carefully and diligently, but it’s a one-off exercise and from then on you can add new images as required.

This is what the modified jcr_image_custom outputs:

Thank you, Jakob.

That screenshot of jcr_image_custom looks awesome. I hadn’t considered using it that way. Very smart set-up.

And that is a beautiful photo! I miss Italy…


JapaneseStreets.com – Japanese street fashion (mostly txp)
Old Photos of Japan – Japan between 1860 and 1940 (100% txp)
MeijiShowa – Stock photos of Japan between 1860 and 1940 (100% txp)

Offline

#16 2021-02-09 15:02:41

Kjeld
Member
From: Tokyo, Japan
Registered: 2005-02-05
Posts: 285
Website

Re: Challenging upgrade and redesign issues 😳

jakob wrote #328676:

My mini-plugin does the same. It strips off the first part of the url if it matches one of the permitted language codes and passes on the rest of the URL for Textpattern to handle as normal. If an incorrect language code is input it defaults to a standard lang code. There’s a tag to output the lang code.

glz_custom_fields in the v2 still works on the latest txp version :-)

Thanks for the additional info, Jakob.

How do you manage the translations for the rest of the site, like the categories, general lay-out, alerts, etc.?


JapaneseStreets.com – Japanese street fashion (mostly txp)
Old Photos of Japan – Japan between 1860 and 1940 (100% txp)
MeijiShowa – Stock photos of Japan between 1860 and 1940 (100% txp)

Offline

#17 2021-02-09 16:03:09

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,087
Website

Re: Challenging upgrade and redesign issues 😳

Kjeld wrote #328678:

How do you manage the translations for the rest of the site, like the categories, general lay-out, alerts, etc.?

The lang prefix plugin provides a tag that outputs en or ja (or whatever) depending on the language of the current page. It will use what’s in the url for that and fall back to a default if not supplied, but if you want to allow people to access articles without there being a language prefix code, you could also store the language code with each article in a custom field and then retrieve that if the url prefix is not available.

Once you have that, you can use it in your page template, e.g.

<txp:output_form form='<txp:jcr_page_langprefix />_header' />

which would output ja_header or en_header depending on the language of the current page.

For general text strings, smd_babel offers a way of adding custom strings. Here too you can name your strings mysite_en_welcome, mysite_ja_welcome, etc.

And then output:

<txp:text item='mysite_<txp:jcr_page_langprefix />_welcome' wraptag="h2" />

to get the respective output.

You can also store the language prefix in a variable …

<txp:variable name="language" value='<txp:jcr_page_langprefix />' />

… and test for it with if_variable, e.g.:

<txp:if_variable name="language" value="ja">
    My Japanese content block
<txp:else />
    My English content block
</txp:if_variable>

… like the categories

I’m not sure how you’re using these. If you have categories in the respective language that correspond to each other, you need a way to map them. It’s the same principle as for sections. e.g.

Variant 1 – A variable map of all sections/categories

Create a form in which you “explain” to TXP how your respective sections and categories link to each other across the languages, and load that high up on your page. It’s just a kind of list of from->to information.

<!-- section map -->
<txp:variable name="sec_landscape">landschaft</txp:variable>
<txp:variable name="sec_landschaft">landscape</txp:variable>
<!-- category map -->
<txp:variable name="cat_landscape">landschaft</txp:variable>
<txp:variable name="cat_landschaft">landscape</txp:variable>
…

And then to make a link to the corresponding other section or category in your page or form template, you’d do:

<!-- section link -->
<txp:section name='<txp:variable name=''sec_<txp:section />'' />' link title />

<!-- category link -->
<txp:category name='<txp:variable name=''cat_<txp:category />'' />' link title />

with double single quotes for the tag-in-tag-in-tag (I know 🙄). That should link to the respective other language section or category of the one you are currently on. So, if you are currently on the “landscape” section, the link would be to the “landschaft” section, and vice versa.

Variant 2 – Using jcr_section_custom

Instead of creating the “map” up front, you can describe the relationship between the sections with each section. With jcr_section, you can add up to five new custom fields for a section. You could create one called, for example partner_section, and then …

In the edit section pane for the “landscape” section, you’d put “landschaft” in that custom field, and in the edit section pane for the “landschaft” section, you’d put “landscape” in that custom field (i.e. always the respective other language).

Then, if you want to provide a language switch between sections, you’d just need:

<txp:section name='<txp:jcr_section_custom name="partner_section" />' title link />

The same principle would apply to categories … except … I haven’t made a jcr_category_custom plugin, at least not yet!!

—-

If, on the other hand, you have categorised your photos according to the same categories, but all you need is to show a different title for your category in the respective language, e.g. all your articles/images are assigned to the category name “landscape”, but you want to show “Landschaft” on a German page, then you could create a smd_babel string for that, e.g. de_cat_landscape = “Landschaft” and then output it with:

<txp:text item='de_cat_<txp:category />' />

or, if I were to make the jcr_category_custom plugin, then you could use a category custom field to store the German (or Japanese) title of the category alongside the regular category title. You’d reference your category as normal, but use the jcr_category_custom tag to output the title in the other language, e.g.:

<txp:category title /> | <txp:jcr_category_custom name="de_title" />

It really depends on your specific setup.

I can imagine that someone might able to come up with a tidier, less verbose way of looking up the respective other languages name/title but this one-to-one map works well enough.


TXP Builders – finely-crafted code, design and txp

Offline

#18 2021-02-09 17:40:41

etc
Developer
Registered: 2010-11-11
Posts: 4,189
Website

Re: Challenging upgrade and redesign issues 😳

Kjeld wrote #328678:

How do you manage the translations for the … general lay-out, alerts, etc.?

It’s a shame there seems to be no way to define LANG and other constants otherwise than in config.php. An early bigbang callback, maybe?

Offline

#19 2021-02-09 17:42:52

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,090
Website

Re: Challenging upgrade and redesign issues 😳

etc wrote #328685:

An early bigbang callback, maybe?

Yes!

EDIT: although plugins aren’t loaded at that point…?

Last edited by Bloke (2021-02-09 17:44:22)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#20 2021-02-09 17:46:18

etc
Developer
Registered: 2010-11-11
Posts: 4,189
Website

Re: Challenging upgrade and redesign issues 😳

Bloke wrote #328686:

Yes!

EDIT: although plugins aren’t loaded at that point…?

Drat!

Offline

#21 2021-02-10 03:53:16

Kjeld
Member
From: Tokyo, Japan
Registered: 2005-02-05
Posts: 285
Website

Re: Challenging upgrade and redesign issues 😳

jakob wrote #328680:

The lang prefix plugin provides a tag that outputs en or ja (or whatever) depending on the language of the current page. It will use what’s in the url for that and fall back to a default if not supplied, but if you want to allow people to access articles without there being a language prefix code, you could also store the language code with each article in a custom field and then retrieve that if the url prefix is not available.

Once you have that, you can use it in your page template, e.g.

<txp:output_form form='<txp:jcr_page_langprefix />_header' />...

which would output ja_header or en_header depending on the language of the current page.

For general text strings, smd_babel offers a way of adding custom strings. Here too you can name your strings mysite_en_welcome, mysite_ja_welcome, etc.

And then output:

<txp:text item='mysite_<txp:jcr_page_langprefix />_welcome' wraptag="h2" />...

to get the respective output.

You can also store the language prefix in a variable …

<txp:variable name="language" value='<txp:jcr_page_langprefix />' />...

… and test for it with if_variable, e.g.:

<txp:if_variable name="language" value="ja">...

I’m not sure how you’re using these. If you have categories in the respective language that correspond to each other, you need a way to map them. It’s the same principle as for sections. e.g.

Variant 1 – A variable map of all sections/categories

Create a form in which you “explain” to TXP how your respective sections and categories link to each other across the languages, and load that high up on your page. It’s just a kind of list of from->to information.

<!-- section map -->...

And then to make a link to the corresponding other section or category in your page or form template, you’d do:

<!-- section link -->...

with double single quotes for the tag-in-tag-in-tag (I know 🙄). That should link to the respective other language section or category of the one you are currently on. So, if you are currently on the “landscape” section, the link would be to the “landschaft” section, and vice versa.

Variant 2 – Using jcr_section_custom

Instead of creating the “map” up front, you can describe the relationship between the sections with each section. With jcr_section, you can add up to five new custom fields for a section. You could create one called, for example partner_section, and then …

In the edit section pane for the “landscape” section, you’d put “landschaft” in that custom field, and in the edit section pane for the “landschaft” section, you’d put “landscape” in that custom field (i.e. always the respective other language).

Then, if you want to provide a language switch between sections, you’d just need:

<txp:section name='<txp:jcr_section_custom name="partner_section" />' title link />...

The same principle would apply to categories … except … I haven’t made a jcr_category_custom plugin, at least not yet!!

—-

If, on the other hand, you have categorised your photos according to the same categories, but all you need is to show a different title for your category in the respective language, e.g. all your articles/images are assigned to the category name “landscape”, but you want to show “Landschaft” on a German page, then you could create a smd_babel string for that, e.g. de_cat_landscape = “Landschaft” and then output it with:

<txp:text item='de_cat_<txp:category />' />...

or, if I were to make the jcr_category_custom plugin, then you could use a category custom field to store the German (or Japanese) title of the category alongside the regular category title. You’d reference your category as normal, but use the jcr_category_custom tag to output the title in the other language, e.g.:

<txp:category title /> | <txp:jcr_category_custom name="de_title" />...

It really depends on your specific setup.

I can imagine that someone might able to come up with a tidier, less verbose way of looking up the respective other languages name/title but this one-to-one map works well enough.

Thank you very much for all the additional information, Jakob.

Your plugins seem to offer far more potential functionality than I imagined. I will have to take some time to study your advice more carefully. The best is probably to fiddle with your plugins on a dev site.

Is there a multilingual site that you have developed based on this advice that I may have a look at?


JapaneseStreets.com – Japanese street fashion (mostly txp)
Old Photos of Japan – Japan between 1860 and 1940 (100% txp)
MeijiShowa – Stock photos of Japan between 1860 and 1940 (100% txp)

Offline

#22 2021-02-10 09:04:28

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,087
Website

Re: Challenging upgrade and redesign issues 😳

Kjeld wrote #328691:

Is there a multilingual site that you have developed based on this advice that I may have a look at?

I’d have to ask as the site was not one of my own. I had a test account but it no longer has admin rights so one can’t see the principle. I guess that would only work through screen sharing pending permission.

The best is probably to fiddle with your plugins on a dev site.

This may be simplest: a general structural setup that echoes want you want to have and some basic test content to test practical implementation without doing open-heart surgery on your actual site. Feel free to email me off-forum if you like.


TXP Builders – finely-crafted code, design and txp

Offline

#23 2021-02-10 09:25:06

Kjeld
Member
From: Tokyo, Japan
Registered: 2005-02-05
Posts: 285
Website

Re: Challenging upgrade and redesign issues 😳

jakob wrote #328694:

I’d have to ask as the site was not one of my own. I had a test account but it no longer has admin rights so one can’t see the principle. I guess that would only work through screen sharing pending permission.

I don’t require admin access. I would just like to have a look at the lay-out for general understanding, and the page source to see how the multilingual implementation looks to search engines.

This may be simplest: a general structural setup that echoes want you want to have and some basic test content to test practical implementation without doing open-heart surgery on your actual site. Feel free to email me off-forum if you like.

That is very kind of you, Jakob. Thank you!


JapaneseStreets.com – Japanese street fashion (mostly txp)
Old Photos of Japan – Japan between 1860 and 1940 (100% txp)
MeijiShowa – Stock photos of Japan between 1860 and 1940 (100% txp)

Offline

Board footer

Powered by FluxBB