Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2019-05-02 00:21:11
- mori
- New Member
- Registered: 2019-05-01
- Posts: 9
Multi-Lingual Site
Hello,
I’m new to Textpattern, and if possible, I’d really like to stay away from WP! I like the clean feel Textapttern has.
Anway, I tried searching for anything related to multi-lingual sites on this forum and read the multi-site installation documentation.
I came across Multi-Lingual Language Pack, but that doesn’t seem to be compatible with the latest Textpattern, and closest solution I found was a thread from 2012- https://forum.textpattern.com/viewtopic.php?id=37824
Although I’d have my site translated into different languages, the sites would share a lot of the same images. The forum post I linked above seemed to have mentioned a way to make the sites share one image folder in the admin > preferences > advanced panel.
I was thinking about using subdirectories to hold the different translations of the site (e.g. ../en, /zh etc), but that doesn’t seem to be how it’s done in Textpattern, since the multi-site documentation only mentioned subdomains. I could go the subdomain route if subdirectories isn’t an option.
What might be the easiest way to achieve what I’m trying to go for (largely the same images, but translated articles, menu texts, navi bar texts etc.)?
Thank you in advance.
Last edited by mori (2019-05-02 00:22:17)
Offline
Re: Multi-Lingual Site
Hello and welcome to the forum!
I guess it depends how complex your site is and whether you want them to share the same URLs.
MLP is/was a pretty comprehensive solution with term lists for the different languages and separate version texts for the same article … but in a separate area of the admin area.
In the article you link to, there’s some talk of having two databases/sites/installations that share a single image directory. I think that need not necessarily apply to your site. In a standard Textpattern installation, there’s only one Content › Images panel, so if all your articles are in the same installation, that’s not an issue at all.
If your needs are not tooo complex, you may be able to achieve what you want with in-built means and some small(er) modifications. Some ideas:
If you don’t need your urls to be the same with a different language prefix/suffix and you can find non-overlapping section names specific to your languages, you can in effect write individual articles in each language, each in their own language-specific menu sections. They can reference the same image, or a different one, if you need to alter images to make them language-specific. With this setup, you’d have:
sitedomain.com/about-us
sitedomain.com/ueber-uns
sitedomain.com/a-propos-de-nous
To link different language articles to each other, you can use one or more custom_fields in an article that holds the respective article ID of the other language. You can then design your language switcher to switch between the correct articles (if they exist) so that you can switch between languages at the article level.
To link different language menu sections to each other, you can set up a list of variables that indicate which is the section name in the parallel language. By naming the variables according to a pattern, you can make your language switcher switch between the correct sections at the section landing page level.
For the navigation you can likewise use a variable to hold the list of sections that should appear in each language. While you can use a cookie to keep track of which language you are on, it’s not strictly necessary here as this method essentially uses several sets of article trees and you restrict the menu sections to those that you need for each language.
For text snippets/phrases that occur in each language, either you hard-code them into the templates, or you make a list of language items that you name according to a pattern with a language prefix so you can show the relevant text item depending on the language being viewed. You can enter these snippets in the language pane, but I remember there was a plugin mentioned recently for editing custom text items.
All in all, this method is quite feasible, but requires thinking about your needs and how to set things up. It’s not install a plugin and go. Some other aspects may also need special solutions, e.g. if you want separate language RSS feeds, etc.
One site I produced this way is no longer online (the owner eventually switched to Wix :-/), but if you’re seriously interested, I can spin it up on a test domain to look at.
Another idea with a different setup follows in the next post…
TXP Builders – finely-crafted code, design and txp
Offline
Re: Multi-Lingual Site
Another idea with a different url structure and article saving method:
A while back I did a brief proof of concept for someone who wanted to replicate their old url scheme using Textpattern. Part of that involved a language switcher (see this thread). The site uses an url query to specify the language to produce urls like this:
sitedomain.com/content.php?section=architects&language=fr
sitedomain.com/content.php?section=architects&language=en
sitedomain.com/content.php?section=architects&language=de
sitedomain.com/content.php?section=architects&article=ando&language=fr
… and …
sitedomain.com/content.php?section=artists&language=fr
sitedomain.com/content.php?section=cities&language=en
… and so on …
The @content.php? and “messy” urls was what they wanted, so that was non-standard, but it could have been more human-readable:
sitedomain.com/architects/ando?language=fr
sitedomain.com/architects/ando?language=en
sitedomain.com/architects/ando?language=de
…
and that might be reworkable (or url rewritable) into sitedomain.com/fr/architects/ando
and so on. Unfortunately, after requesting me to do a proof of concept the poster never replied ? so I didn’t pursue it any further. I could revisit it if of interest.
You can see it here: cabin-chair.txpbuilders.com. If you click around, you can see how it behaves and what happens when there is no article in the other language.
The organisational scheme in this case is much simpler: there is only one article – so the URL is identical, except for the language identifier – and each article has several body fields, one for each language. If you need several titles, you’d need several title fields for the separate languages, and so on.
This method would work elegantly for a simple site where you’re fine with the section and article urls being identical for all languages and you only need certain information in each language. There comes a point where if you need a lot of article fields in 2 or 3 languages, it may be simpler to go with separate articles for each language that are interlinked as described above.
One other aspect to consider: the method in this post gives you predictable url structure of the type /section-name/article-url-title?language=en
(or potentially /en/section-name/article-url-title
) but you lose the SEO potential or language-specific url names. With the method described in the previous post, your section name and article url title can be specific to the respective language.
There are probably other ways too…
TXP Builders – finely-crafted code, design and txp
Offline
#4 2019-05-02 10:02:20
- mori
- New Member
- Registered: 2019-05-01
- Posts: 9
Re: Multi-Lingual Site
Thank you for the detailed solution! I very much appreciate it.
I won’t have complex features except one – the possibility of an e-commerce plugin; that said, I’d probably put a link to a 3rd party e-commerce site.
As far as I can see, my site would have:
- a gallery
- flipbook-like plugin, but that’s a type of gallery I guess. I could try to roll my own if necessary, but I wouldn’t count on my coding skills.
- static pages – just text and images. I doubt I’ll include videos an such
- maybe an shopping cart + checkout plugin. I see that the only e-commerce plugins in Textpattern’s repo are for Google Checkout which has been retired unfortunately. Again, I wouldn’t count on myself for making such a complex plugin. 3rd party service looks like the way to go.
I don’t foresee RSS feeds. Possible comments, but I doubt it’d come anytime soon.
To confess, I haven’t dived into the documentation yet, so I didn’t quite understand how sections work- I’ll read up on it. In the 2012 article, someone mentioned using sections as the language-prefix in the URL. I’m guessing that’s kind of a bad idea and not how Textpattern intended sections to be used… and that it’ll backfire in the future if I used sections that way.
Yes, it’d be convenient to have the same url prefixed with different language codes, but I could work around it by simply adding the language code as a suffix.
Update: It just so happens that you posted while I was finishing editing this post. Those are some nice solutions! My site will start out simple and probably stay that way for a while, so the second solution would work well. I’ll think about how much the SEO loss would impact me.
I have no idea on the inner workings of Textpattern just yet. I’m guessing that the solution involving passing a language query would let the server do some server-side-processing and take out the unnecessary texts before sending it to the client?
P.S.
On another note, there’s a lot of themes in the repository that was made back in 2006/2007. How well would those work with the current version of Textpattern? Would one from 2011 work well?
Thank you again for your wonderful help!
Last edited by mori (2019-05-02 10:24:26)
Offline
Re: Multi-Lingual Site
For reference, the plugin that jakob mentioned to manage language string translations from the administration side is smd_babel.
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
Re: Multi-Lingual Site
mori wrote #317854:
I won’t have complex needs for my site. As far as I can see, my site would have:
- a gallery
No problem. If you need captions/alt-text in different languages, you may need a plugin to add extra fields for each language.
- flipbook-like plugin …
Can you show an example of that?
- static pages – just text and images. I doubt I’ll include videos an such
No Problem. Videos also not a problem.
- maybe an shopping cart + checkout plugin at one point. I see that the only ecommerce plugins in Textpattern’s plugin repo are for Google Pay which has been retired unfortunately. Again, I wouldn’t count on rolling such a complex plugin myself, so it looks like I’d be putting a link to another service.
That’s something I’ve rarely implemented but I wasn’t aware that the yab_shop plugin no longer works. Hooking the site up to shopify or some other cart system should be possible though.
To confess, I haven’t dived into the documentation yet, so I didn’t quite understand how sections work- I’ll read up on it.
Sections divide articles into different areas and show in the url scheme. Categories apply across sections. An example: sections could be “clothes”, “shoes”, “bags” while categories could be “cotton”, “leather”, “canvas”, or colours etc. which could apply to any of the sections.
So looking in “clothes” will just show you clothes articles. Filtering all articles by the category “leather”, will give all clothes, shoes and bags made of leather. Filtering by “leather” from within the clothes sections would give you just leather jackets (or whatever).
In short, think of sections as “dividing” (sectioning) content, and categories as attributes of content.
In the 2012 article, someone mentioned using sections as the language-prefix in the URL. I’m guessing that’s kind of a bad idea and not how Textpattern intended sections to be used… and that it’ll backfire in the future if I used sections that way.
In the article, the suggestion was to use “hebrew” as the section name. As Textpattern has just one real level of depth, e.g. /section/article-name
, you can’t make a very complex site that way. In the case described on that site, it would not have been possible to add further site subdivisions. But you could do section names like this:
en-clothes
de-clothes
fr-clothes
The difference is purely visual, though perhaps it makes coding the template a little easier than doing
clothes
kleidung
vetements
That also illustrates the relative benefits of simple urls or seo-friendly urls.
Yes, it’d be convenient to have the same url prefixed with different language codes, but I could work around it by simply adding the language code as a suffix.
In the second example I showed above, there may be a way to use a prefix rather than a suffix. I’d need to investigate. The prefix is certainly cleaner :-)
On another note, there’s a lot of themes in the repository that was made back in 2006/2007. How well would those work with the current version of Textpattern? Would one from 2011 work well?
Which repository do you mean? In the most recent Textpattern version (4.7+), theming has been revised and made much easier. The basic principles and tag system is the same as ever, so older themes may work, but Textpattern has grown and improved in the last 10+ years significantly, so a lot of the workarounds in old themes are often unnecessary now.
TXP Builders – finely-crafted code, design and txp
Offline
Re: Multi-Lingual Site
Bloke wrote #317855:
For reference, the plugin that jakob mentioned to manage language string translations from the administration side is smd_babel.
Yep! That was it. Thanks for adding that (and writing the plugin).
TXP Builders – finely-crafted code, design and txp
Offline
#8 2019-05-02 10:28:28
- mori
- New Member
- Registered: 2019-05-01
- Posts: 9
Re: Multi-Lingual Site
My apologies. The “repository” I was referring to was https://textpattern.org
I was browsing plugins and templates.
A flipbook example would be something like this
Note – I have never used this plugin, but the basic functionality seems pretty straightforward from the screenshot. Anything that can put two images side-by-side and use the full vertical space of a monitor would be perfect. I don’t need any special flip-effects. If there isn’t already a similar, then something like lightbox would be fine. I could probably code a very simple that fits the bill if I’m desperate. – though, I’m really worried about possible security holes should I ever code something for production use.
The prefix language code you mentioned is also a nice solution.
Thank you for all the help! I’ll dig around a bit, and hopefully I can put something good.
Last edited by mori (2019-05-02 11:00:05)
Offline
Re: Multi-Lingual Site
Thanks for the clarification.
Flowpaper is available for use outside of Wordpress but the free version has some potentially crippling limitations (like 10 pages max.). I’m sure there are plenty of similar things out there, for example turn.js or wowbook to name a few, and you can also host your PDFs in issuu or yumpu and use their embedded players, that also work well on mobile displays. If you don’t need to show PDFs, maybe try one of the many slider plugins – slick, owl, flickity, glide … – set to show two items in the carousel frame view.
Regarding the the older templates on textpattern.org, you can try and see how far you get with them. The main difference now is that you don’t need any template import plugin as Textpattern 4.7 now has template importing.
By way of example, this is what you’d do for the minimum theme:
- Download the repository from GitHub
- Make a folder called
minimum
- Copy the
forms
,pages
andstyles
folders into it. - In the
pages
folder, rename the file extensions from.page
to.txp
. - in the
forms
folder, make some foldersarticle
,comment
,file
,link
andmisc
and move the___.misc.form
files into the misc folder, and___.article.form
files into the article folder, and so on. Then rename all the file endings from___.misc/article/image/link/file.form
to.txp
. - Now make a text file called
manifest.json
in theminimum
folder and put this in it:
{
"title": "Minimum",
"txp-type": "textpattern-theme",
"version": "4.7",
"description": "Minimum theme for Textpattern CMS 4.7.",
"author": "Stephan Hochaus",
"author_uri": "https://github.com/yauh/txp-minimum"
}
And save that. Take a look at the default theme to see an example of how it should look in the end.
Now move the entire folder to the /themes
folder of your textpattern installation. When you visit Presentation › Themes, you should now be able to import Minimum from disk.
The last bits you’ll need to do is add the section names that don’t already exist as shown here.
And install the plugins the theme recommends. Of the plugins that the minimum theme suggests, cxc_templates is not necessary. The others should all work but all can be replaced by txp’s own built-in tags. To install them, visit that page in Github, e.g. here, click on the Raw
button and copy the long string of letters and numbers to the clipboard. Visit Admin › Plugins
and paste that string of letters and numbers into the install plugin textbox and click install and then activate (switch to “on”).
TXP Builders – finely-crafted code, design and txp
Offline
#10 2019-05-03 03:37:11
- mori
- New Member
- Registered: 2019-05-01
- Posts: 9
Re: Multi-Lingual Site
I wouldn’t need to show PDFs at all. Images would work perfectly.l
And Thank you again for the very detailed tutorial!
Offline
Re: Multi-Lingual Site
I would like to have the language code as part of the URL: /en/milk, /es/leche, /fr/lait
Is the best way to do this to make sections for “en”, “es”, and “fr”?
And a related question, how do you get URLs with multiple sub-directories like this:
/en/about/history/first-10-years
When you add a “/” in the article URL, it converts to “%2F”. If you add a “/” in the section name, it converts to a hyphen (“-”).
Offline
Re: Multi-Lingual Site
agovella wrote #317896:
I would like to have the language code as part of the URL: /en/milk, /es/leche, /fr/lait
Is the best way to do this to make sections for “en”, “es”, and “fr”?
That approach is possible if you only need one level of depth beneath, e.g. “en”, “es”, and “fr” are sections and “milk”, “leche” and “lait” are articles. Judging by your next question you want more depth, though.
Another approach: It would be conceivable to use an .htaccess
rewrite to convert /(en|es|fr)/
to an url variable such as lang=$1
, i.e. an url like /en/milk
would be rewritten to /milk?lang=en
or index.php?s=milk&lang=en
before being passed to textpattern. With this approach, “milk” is the section, so you could have another level to your URLs, such as /en/milk/lactose-free
…
You’d then use a plugin like adi_gps or rah_gps to retrieve the lang url variable as a textpattern variable for using on your page. You’d also need to construct your own permlinks and section/category links as the standard functions won’t include the language part of the url. That’s not difficult, though.
And a related question, how do you get URLs with multiple sub-directories like this:
/en/about/history/first-10-years
That’s something of a holy grail. Out of the box, you can only get the url schemes in the drop-down on the Admin › Settings panel. You can fake depth in your menu structure but your actual urls are still of the /section/article-title
or /category/category-name
type.
In your example, you might have:
menu | url | textpattern |
About | /about | section |
About › History | /about/history | article |
About › History › First 10 years | /about/history-first-10-years | article |
… and so on.
Two other thoughts:
1) The plugin rah_pathway allows you to give an article a completely user-defined url including forward slashes. While it doesn’t add any actual depth structure to Textpattern, it would enable you to fake the last line of the above table to look like this:
menu | url | textpattern |
About › History › First 10 years | /about/history/first-10-years | article |
You would again need to construct your own permlinks. The plugin puts the user-defined url in a custom field, which is helpful for doing that.
2) There was a plugin called gbp_permlinks that worked with earlier versions of textpattern. It was extraordinarily powerful at making custom url schemes for different sections, also with user-definable snippets in the url, but it was also notoriously difficult to use and I think no longer compatible with current versions of textpattern. That would require some archeological reconstruction work (probably paid) from a plugin author but was much more powerful.
BTW: I have your book in my shelf here!
TXP Builders – finely-crafted code, design and txp
Offline