{"id":19331286,"url":"https://github.com/reachweb/locale-lander","last_synced_at":"2025-04-22T23:31:52.173Z","repository":{"id":218966394,"uuid":"747137142","full_name":"reachweb/locale-lander","owner":"reachweb","description":"Statamic addon that redirects the user to the site in his browser's locale.","archived":false,"fork":false,"pushed_at":"2025-03-01T11:02:25.000Z","size":151,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-18T20:07:29.208Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.reach.gr","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/reachweb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-23T10:41:41.000Z","updated_at":"2025-03-01T11:00:08.000Z","dependencies_parsed_at":"2024-01-24T19:09:10.835Z","dependency_job_id":"d9aa3f6a-207c-4b82-8f56-41002fd5ab8f","html_url":"https://github.com/reachweb/locale-lander","commit_stats":null,"previous_names":["reachweb/locale-lander"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reachweb%2Flocale-lander","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reachweb%2Flocale-lander/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reachweb%2Flocale-lander/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reachweb%2Flocale-lander/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/reachweb","download_url":"https://codeload.github.com/reachweb/locale-lander/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250340312,"owners_count":21414520,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T02:39:34.687Z","updated_at":"2025-04-22T23:31:51.893Z","avatar_url":"https://github.com/reachweb.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"![locale_lander_bg](https://github.com/reachweb/locale-lander/assets/7423993/54b3f81a-8341-4182-94bb-85e60e149ad5)\n\n# Locale Lander\n\nLocale Lander is a simple addon for Statamic, particularly useful for multi-site setups involving multiple languages. It redirects users to the **default language of their browser** during their first visit or displays a banner informing the user that the content is available in their native language.\n\n## How to Install\n\nInstall using composer:\n\n```bash\ncomposer require reachweb/locale-lander\n```\n\n## How to Use (Redirection)\n\nTo use the redirection feature, no additional configuration is needed after installation. The addon should function right out of the box.\n\n## How to Use (Banner)\n\nTo use the banner feature, Locale Lander provides a tag called, you guessed it, `locale-lander`.\n\nFirst, you must disable automatic redirection. Publish the config file:\n\n```bash\nphp artisan vendor:publish --tag=locale-lander-config\n```\n\nand in `config/locale-lander.php` disable redirection:\n\n```php\n'enable_redirection' =\u003e false,\n```\n\nThen, you can use the tag by adding the necessary code to a file that loads on all pages of your website, usually `layout.antlers.html`.\n\n```\n{{ locale_banner }}\n    {{ if entry }}\n        {{ partial src=\"vendor/locale-lander/banner\" }}\n    {{ /if }}\n{{ /locale_banner }}\n```\n\nThe tag will return an `array` that always contains an 'entry' key. If the Entry is unavailable in this locale, `entry` will be false. Otherwise, it will contain the `title` and the `url` of the entry. A `site` key is also provided with information about the user's locale site.\n\nAs you might have guessed, the addon contains an example banner template, styled with *Tailwind CSS*, that works out of the box.\n\nPublish the template:\n\n```bash\nphp artisan vendor:publish --tag=locale-lander-views\n```\n\nand you should be good to go. If you are not using Tailwind CSS, you will need to style it yourself.\n\nIn case you want to implement your own version, note that you should set a cookie named `locale_banner_closed` to prevent showing the banner to users who have closed it.\n\n## How it Works\n\nThis addon automatically applies a middleware in the `statamic.web` middleware group. Here's the process:\n\n- It checks the user's **browser language** and the **sites** defined in `statamic/sites.php`.\n- If the current site's locale **differs** from the user's browser, it verifies if a site for that locale exists.\n- If such a site exists and the current entry is **available** in that locale, it redirects the user there.\n- A **session variable** is set to avoid repetitive redirection. This prevents redirect loops and accommodates users who prefer a different locale than their browser’s default.\n\n## Common Issues\n\n- The addon functions with URLs resolving to an `Entry`. It won't work if the first page a user visits isn't an Entry. (Future improvements are planned for this issue.)\n- If the site's default locale matches the user's, or if the user initially visits the site in their locale but chooses to visit a different one, they will be redirected back to their original locale **once**. I am currently working to resolve this issue, but it may require modifications to the language switcher.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freachweb%2Flocale-lander","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freachweb%2Flocale-lander","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freachweb%2Flocale-lander/lists"}