Jump to content

Allow translators to work on "hidden" language


maba
 Share

Recommended Posts

Hi,

what is the right way to allow a translator to translate the whole content of a site in a new language?

If the new language is hidden he cannot view the new language tab in translatable fields.

If the new language isn't hidden we see it in front-end in language switch (example). Something like "unpublished" also for the language page.

Thanks,

Marco 

Link to comment
Share on other sites

If you just created a new language, edit you homepage settings and set that language as Inactive there. But if you already have a language activated and some pages translated, you will need to inactivate the language in all pages I think.

Link to comment
Share on other sites

Thanks Sérgio,

but:

- even if a language is set as inactive site.com/fr works and not throws a 404 (this happens only when a language is hidden)

- my switch language menu retrieves the inactive language also (probably a check like isActive is enough in this case)

Link to comment
Share on other sites

- even if a language is set as inactive site.com/fr works and not throws a 404 (this happens only when a language is hidden)

You can create a .htaccess redirect rule for that, a non-permanent redirect. And disable it when the translation is ready.

- my switch language menu retrieves the inactive language also (probably a check like isActive is enough in this case)

Yep. :D

Link to comment
Share on other sites

I met my client and now I have to exclude .htaccess and other.. they would see how the translated text render on the production site. :(  :huh:  

Luckily, a second request can be solved with the awesome features added in 2.6.{2,3}.  ^-^

Link to comment
Share on other sites

Another approach I've used in the past is to implement a simple language status handler. Basically I added fields to languages and had a bit of code that would display a page or not based on the status of a page translation. Mine was used to display a notice to users, but it could just as well be used to do redirects or throw 404s.

  • Like 1
Link to comment
Share on other sites

Ok, with 2.6.10 the problem with my menu is gone.. 

Thanks Pierre-Luc. 

To simplify the problem I can use a simple check for guest user for now, follow your suggestion and keep active all languages.

Do you add the "status" field directly in language template?

Link to comment
Share on other sites

  • 1 month later...

Hiyall, I have the same problem, with Processwire 2.6.1. A multilingual site that was published with only the default language content. The translations will be added afterwards, and for now I've just commented out the language switcher (not sustainable!).

Problem: Google finds all the not-yet-translated pages, and in fact favours them rather than the default language pages, which don't show in the search results at all.

All pages have the "Active?" checkbox unchecked in these not-yet-translated pages. How are the pages still accessible?

Before there's a fix in the core for this bad behaviour, I'd be happy to get some help with this quick'n'dirty .htaceess method to prevent these pages to be seen, but my .htaccess skills are still in the level of copy+paste. And the .htaccess method ain't good in the long run anyway, as clients would have to call us every time they've finished a translation and want it live. But before then we'd really need this to work.

My attempt in the .htaccess:

RedirectMatch    307    /en/(.*)    /$1
RedirectMatch    307    /se/(.*)    /$1

Not working. domain.com/en/yhteystiedot will redirect to domain.com//yhteystiedot?it=en/yhteystiedot (and shows an 404 page there), when I'd just like to get rid of the language code, ending up to domain.com/yhteystiedot.

I'd be happy with redirect to a 404 or even the frontpage rather than the same url without the language code, if Google wouldn't find these not-yet-translated pages, but the default language pages (without the language code in the url) instead.

Help, anyone?

Link to comment
Share on other sites

@tkaranka

Hello,

I created a multilingual website (just a few pages for the moment) not long ago (Processwire 2.6.1).

With French as the default language (default     fr) and the old/default default language as the secondary language (en     en).

I have Language "fr" enabled for the guest user.

In the backend I only have the "fr" tabs activated (*).

I didn't comment out the language switcher (but I could also).

I have only "fr" at the top of the website (that I could hide with css, for example, if I wanted) (*).

My "Default language homepage is same as root URL".

(*) For Languages > en > Settings > Status, I have "Hidden: Excluded from lists and searches" currently enabled.

If this is enabled, if I add en to http://domainname.tld/ I arrive on a "404 Page".

I didn't uncheck "Active?" in the homepage Settings (the setting is visible only if "Hidden: Excluded from lists and searches" is not enabled).

In the source code I have:

<link rel='alternate' hreflang='fr' href='http://domainname.tld/' />

On all default pages except the homepage, /fr/ is added to the url.

(Did you try with RewriteCond and RewriteRule?)

Link to comment
Share on other sites

Thanks, @Christophe

I haven't yet noticed the Languages > en > Settings > Status, which of course is the most logical place for site-wide language settings. D'oh! Enabling the "Hidden" checkbox does redirect the urls with language code to 404 page, whis is exactly what was needed as a quick fix for now. Thank you again!

However, now we (or our customers, to be more precise) can't add in the translations, as the language tabs in each field in the page edit page are hidden. So the hunt for a right .htaccess rule continues; I haven't found the right copy+paste-able rule(s) just yet, as that's still all I can manage. Will focus on googling RewriteCond and RewriteRule next as per your most helpful suggestion!

Link to comment
Share on other sites

Hello again,

You could try, for example, something like:

# Redirect from Subfolder to Root
RewriteEngine on
RewriteRule ^en/(.*)$ /$1 [R=307,NC]
RewriteRule ^se/(.*)$ /$1 [R=307,NC]

(Did you choose 307 on purpose?)

(Had you submitted a sitemap.xml to Google (Webmaster Tools)?)

NB: perhaps it would work with RedirectMatch without the first slash(?). Just wondering...

Link to comment
Share on other sites

Wow, thanks!

I couldn't get your "something like this" example to work as is (obviously), but after some tweaking I think it's mostly there. Now I have this at the beginning of the .htaccess file:

RewriteRule ^en(.*)$    /    [R=307,L]
RewriteRule ^se(.*)$    /    [R=307,L]

Pros:

- Redirects also the non-translated front pages (/en and /se), not just the content pages (for example /en/some-page).

Cons:

- Will also redirect any URL that starts with letters "en" on "se" in the default language, for example "/enigma" or "/second".

- Redirects all to domain root, not to 404 page.

If there's a way to get rid of the cons while keeping the pros, I'm all ears. Thanks for the awesome answers this far!

Also yup, 307 is on purpose (or would Processwire work better with 302 or 303 in this situation?). The redirect is temporary, because when the translations are ready everything has to work as if the redirects never were there.

There's no sitemap.xml (yet), but the domain has been added to Google Webmaster Tools, just without a sitemap.

Link to comment
Share on other sites

Thanks, LostKobrakai!

This does redirect to 404 (woohoo!), but changes the url to /http404/, too. That's better than the front page, but the best would be to leave the url as is and just show the 404 there (I know, didn't phrase it like that previously, sorry! Getting greedier here). I believe this isn't so easily doable without better understanding of PW's inners and .htaccess, though, so this'll do great for now.

Landing to /se or /en (without the trailing slash) however don't trigger the redirect in your suggestion, so we're back in the drawing board with that bit.

Progress:

RewriteRule ^en(.*)$	/http404	[R=307,L]
RewriteRule ^se(.*)$	/http404	[R=307,L]

Further suggestions from .htaccess gurus (and wannabes, too) are most welcome!

Link to comment
Share on other sites

Hello again,

I'm just a beginner with regex.

I had found the code via Google.

The "$1" part seemed a bit strange to me (in this case). It normally corresponds to the first "capturing group" (that you sometimes/always? put between parenthesis). Perhaps a slash was needed before en or se(?).

"- Will also redirect any URL that starts with letters "en" on "se" in the default language, for example "/enigma" or "/second"."

This seems normal as

.* = .{0,} = match any char zero or more times,

and there is no slash after en or se.

You normally need a slash before (.*), in your case.

You could use (en|se) also apparently or [a-z]{2} (Limits to 2 characters. With or without parenthesis, it depends on the case).

You can test regex codes at https://regex101.com/, http://regexr.com/ or elsewhere.

There is also, for instance, http://regex.learncodethehardway.org/book/. I don't remember if I finished reading everything. I'll probably have to start all over again (one day).

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...