All add-ons currently require PHP 7.4 or greater.

On July 4th 2024 PHP 8.2 will be the new minimum requirement for all add-ons. Expect any add-on released after that date to require 8.2 or greater. Some releases may not immediately take advantage of 8.x specific features in PHP, which means you might, be able to continue using new releases in PHP 7.4, however, if you experience an error the first thing you should do is update to PHP 8.2 then create a support ticket if the error persists.

Publisher does not support the Fluid field type. Please do not contact asking when support will be available.

If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.

Ticket: Let multiple domains share a language

Status Resolved
Add-on / Version Publisher Domain Control 1.0.0
Severity
EE Version 2.10.1

Linus Design

Jun 03, 2015

Hi

The site I’m building will have four separate TLDs:

.com – US english
.co.uk – UK english
.de – German
.hk – Hong Kong

At launch, they want the Hong Kong version to display US english. They will then, at some point, change that to Cantonese. Is there a way, with Publisher Domain Control, to serve .hk the same content as .com, and avoid having a fourth language in Publisher, until it’s needed?

Many thanks, Frank

#1

BoldMinded (Brian)

Yeah, just put the .hk domain name in the Hong Kong Site Url field. All its doing is associating the domain name to the language name (and a couple other things behind the scenes)

#2

Linus Design

But it seems that the only way to get a new Site URL field for HK in the Publisher Domain Control settings is to add HK as a new language in Publisher. What I’d like to do is have the .hk site use the same Publisher language as the .com site. (There may eventually be several TLDs all using US English, a couple of TLDs using French – so if we add each one as a separate language there’s going to be a lot of duplicate data.) Sorry if I’m missing something!

#3

BoldMinded (Brian)

Oh, I see. You might have to add an override to your EE config.php file. Try something like this:

if ($_SERVER['SERVER_NAME'] == 'something.hk') {
    $config['publisher_lang_override'] = 'en';
}
#4

Linus Design

Aha – will give that a go. Thanks!

#5

Linus Design

Yep that does it – thanks loads

#6

Linus Design

Agh, client has now decided that they want everything on one domain, so I have a similar but new issue:

They want two languages, UK english and US english, but four regions:

example.com/uk example.com/us example.com/hk example.com/de

They would like /hk and /de to show the same content as /uk for now. So a lot of duplicate content basically. Is it possible to achieve this with only two languages in Publisher, so they don’t need to worry about saving four versions of everything?

At a later stage they’ll want to do proper translations for hk and de – at which stage we’d need to add those languages in to Publisher properly.

Many thanks

#7

BoldMinded (Brian)

Use the same override $config[‘publisher_lang_override’] = ‘en’; but you might have to change that if conditional to be more of a regex or string search to match the URL.

if (strpos($_SERVER[‘SERVER_NAME’] . $_SERVER[‘REQUEST_URI’], ‘example.com/uk’) !== false) { $config[‘publisher_lang_override’] = ‘lang code here’; }

You may need to play around with the $_SERVER variables, not sure if REQUEST_URI is what you want, but you get the idea. You just need to figure out the current domain name plus the URI path that includes the language segment.

#8

Linus Design

Ah ok – thanks for the swift reply, will have a play with that.

#9

Linus Design

Just tried this but had no effect… So tried putting just:

$config['publisher_lang_override'] = 'uk';

in my config.php but when I visit a german page (eg. example.com/de/about) I see German rather than UK English. Any idea why that might be? ‘uk’ is definitely set up as a publisher language.

#10

BoldMinded (Brian)

You may need to use an early parsed global variable instead.

In your config.php use the same if statement, but assign the value to this:

$assign_to_config[‘global_vars’][‘current_language_id’] = ‘2’;

Then in your entries tag you can use it this way:

{exp:channel:entries publisher_lang_id=”{current_language_id}”}

#11

Linus Design

Thanks Brian. That works for the channel entries tags, but not for {phrase} or {exp:publisher:languages} tags. Is there a way to make it work on those too?

Or might there be some way to get $config[‘publisher_lang_override’] = ‘uk’ to work in this setting? That would be amazing as it’d let me keep the code simple, and I could just remove the config settings when they eventually translate to all languages.

Thanks for all your help, it’s much appreciated!

#12

BoldMinded (Brian)

Comment has been marked private.

#13

Linus Design

Actually it’s “Frank”! But thanks for the new version - will try that now…

#14

Linus Design

Hmm, that seems to give a redirect loop. I upgraded to the version you sent, then added back:

$config["publisher_lang_override"] = "uk";

into config.php, but now when I visit any non-default-language version of the site, Chrome says “This webpage has a redirect loop”.

#15

BoldMinded (Brian)

Frank, if that didn’t work then I’m not sure I want to try to make this work. Not that I don’t want to help make this easier for you, but if I start screwing with the language switching much more I could potentially introduce bugs for other people. Its already a complex process. Since this is an edge case with such a unique request I suggest you revert to the early parsed global variable to set the language id and use publisher_lang_id in the entries tag as mentioned above, and for phrases use the full module tag: {exp:publisher:translate_phrase name=”foo” lang_id=”x”}

#16

Linus Design

Comment has been marked private.

#17

BoldMinded (Brian)

That sounds like the Display Fallback setting option, make sure its turned on.

#18

Linus Design

Thanks Brian, didn’t spot that in the CP and I’d been scouring the docs which don’t seem to include it. Going to talk through all this with the client – I’m sure that either this or the early parsed global variable will work.

One thing I noticed is that if you have:

Display Fallback ON Persistent Entries ON Persistent Matrix/Grid OFF

… then visit a page that uses a Grid field in a language that doesn’t have a translation done, you get all of the default-language content except for the Grid field. Not a deal-breaker at the moment, but would be nice to fix if possible.

Thanks again for the support – site launches this Friday so it’s been a life-saver!

#19

Linus Design

.. Also related to my last comment: if you have the above settings and create a channel with a matrix field that contains a playa field, save in just the default language, and visit front-end in non-default language, matrix displays fine (in default language as expected) but playa fields don’t seem to work.

#20

BoldMinded (Brian)

Thanks for the feedback. It’ll probably be a few days before I can start looking into this.

#21

Linus Design

No problem - thanks

#22

BoldMinded (Brian)

I’ve obviously haven’t been able to look into this, and after re-reading the ticket I don’t think I’m going to make any fundamental changes to how the languages work in Publisher 2 and Publisher 1 development has ended.

Login to reply