Welcome Guest, Not a member yet? Register   Sign In
Routing {locale} : Duplicate Content [SOLVED in next release]
#1

(This post was last modified: 06-30-2022, 07:38 AM by InstantT.)

Hi all,
When we use the "{locale}" tag in a route, it can generate Duplicate Content, even when using the $supportedLocales variable

For example if I use :
PHP Code:
public $supportedLocales = ['en''fr']; 


When I go to a url of type
- mywebsite.com/en/page.html = code 200 ("en" version)
- mywebsite.com/en/page.html = code 200 ("fr" version or "en" version if "fr" does not exist)
- mywebsite.com/lorem/page.html = code 200 ("en" version)
- mywebsite.com/codeignitertest/page.html = code 200 ("en" version) etc.

Do we have to check in our Controller that the language exists?
And if yes, how to get the information from the $supportedLocales variable?

Otherwise, wouldn't it be interesting in the next version, to put an option to avoid this duplicate content

For example, if {locale} does not correspond to any language present in $supportedLocales, then, we return a 404 error

Regards

Ps : The variable "$supportedLocales" is defined as "@var string[]"

What is the difference with "@var array"? (it's just for my personal culture Smile )
--- I am not a developer ---
Reply
#2

(This post was last modified: 06-29-2022, 02:48 PM by kenjis.)

(06-29-2022, 10:09 AM)InstantT Wrote: Do we have to check in our Controller that the language exists?
And if yes, how to get the information from the $supportedLocales variable?

Otherwise, wouldn't it be interesting in the next version, to put an option to avoid this duplicate content

For example, if {locale} does not correspond to any language present in $supportedLocales, then, we return a 404 error

Yes, you need to check now.

And v4.3 will have the option.
See https://github.com/codeigniter4/CodeIgniter4/pull/6073

(06-29-2022, 10:09 AM)InstantT Wrote: Ps : The variable "$supportedLocales" is defined as "@var string[]"

What is the difference with "@var array"? (it's just for my personal culture Smile )

string[] means array of string items.
Controller[] means array of Controller objects.
Reply
#3

(This post was last modified: 06-30-2022, 07:37 AM by InstantT.)

Thank you @kenjis

So I will wait for the release of this new version Smile

I'm still not sure I understand the difference between "string[]" and "array" (not Controller)
--- I am not a developer ---
Reply
#4

(This post was last modified: 06-30-2022, 07:43 AM by iRedds.)

string[] means that the array contains only strings as values. ['a', 'b', 'text', ]
array - means that it is an array with any content. ['a', 1, new stdClass, null, false]

This gives an idea of what the array contains, and in the case of the IDE, you can get hints.
Reply
#5

@iRedds : Thank you very much for this clarification.

I understand Smile
--- I am not a developer ---
Reply




Theme © iAndrew 2016 - Forum software by © MyBB