=== WakaLang ===
Contributors: noricku, wakalab
Tags: multilingual, translation, hreflang, language-switcher, i18n
Requires at least: 6.4
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 0.1.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Keep visitors in their language. Lightweight URL-prefix language routing, hreflang, and a language switcher for WordPress.

== Description ==

WakaLang is a lightweight multilingual plugin for WordPress. It keeps the visitor's chosen language stable across the whole site using clean, URL-prefixed addresses (for example `/en/about/` and `/ja/about/`), and is designed to be simple for manual translation workflows on technical blogs and documentation sites.

The free plugin is fully usable on its own and makes no external network calls.

**Free features**

* Register the languages your site offers (code, locale, names, URL prefix, default).
* URL-prefix routing: every page is reachable under each language prefix (`/en/…`, `/ja/…`), with the prefix as the single source of truth for the active language.
* A language switcher with automatic header/footer placement, an editor block, the `[wakalang_switcher]` shortcode, and the `wakalang_language_switcher()` template function — with optional flags rendered as Unicode emoji (no external requests).
* `hreflang` alternate links (and an optional `x-default`) for translated content.
* Internal links, menu links, the site/home link, and block-theme (FSE) navigation all keep the current language's URL prefix.
* Link posts, pages, and taxonomy terms into translation groups from a post or term editor, and create draft translations.
* Archive, search, RSS/Atom feeds, and the core `wp-sitemap.xml` are scoped to the current language.
* Translate taxonomy terms (category, tag, custom taxonomy) with per-language name and slug.
* Manage a per-translation SEO title and meta description, handed to WordPress core and to Yoast / Rank Math (their own meta is never touched).
* Translate the site title and tagline per language.
* The admin locale follows the URL language so editing screens match the language you are working in.
* Filter the post list by language and review an untranslated-coverage report on the Tools screen.
* Works alongside Markdown Renderer for GitHub: WakaLang owns the site-wide language spine without duplicating its switcher.

**Privacy**

WakaLang does not call any external service, does not track visitors, and stores no personal data. It runs entirely on your own site.

**Third Party Services**

WakaLang Free does not connect to any third-party service, CDN, telemetry endpoint, license server, or translation API. It serves its assets from your WordPress site and performs language routing locally.

**Optional add-on**

A separate paid add-on is planned for AI-assisted, Markdown-safe translation using an administrator-provided API key, glossary, translation memory, and differential translation. The free plugin contains none of that add-on code and works fully without it.

== Installation ==

1. Upload the `wakalang` folder to `/wp-content/plugins/`, or install it from the Plugins screen.
2. Activate the plugin.
3. Go to **WakaLang → Languages** to register your languages and set a default.
4. Go to **WakaLang → Settings** and choose a header or footer language switcher position, or add the block/shortcode where you want it manually.

== Frequently Asked Questions ==

= Does WakaLang send my content anywhere? =

No. WakaLang Free makes no external network calls, does not use a CDN, does not include telemetry, and does not perform license checks.

= How does WakaLang decide the current language? =

From the URL prefix (for example `/en/`). The prefix is authoritative; visitors are never silently redirected away from the language they are viewing.

= Can I use WakaLang without an add-on? =

Yes. The free plugin is complete for manual multilingual sites: register languages, use URL prefixes, link translated posts, output a switcher, and publish hreflang alternates.

= How do I show a language switcher? =

Choose "Page header" or "Page footer" under **WakaLang → Settings → Language switcher position** to show the switcher in the site layout instead of inside post content. You can also add the Language Switcher block, place the `[wakalang_switcher]` shortcode in content, or call `wakalang_language_switcher()` from a theme template. You can show country flags (rendered as Unicode emoji, no external requests) with the `flags` option set to `flag` or `flag_and_name`. To turn the switcher off everywhere without removing it from your content, toggle "Show language switcher" off on the Settings screen.

= How do I link a post to its translation in another language? =

Open the post or page editor and use the WakaLang meta box to set the post's language and link it into a translation group. From there you can see the other-language versions and create a draft translation to fill in. Taxonomy terms are linked the same way from the term editor. WakaLang stores these relationships in its own table and removes them automatically when a post is deleted.

= Do menus and internal links follow the current language? =

Yes. While a visitor is on `/en/`, menu links, internal permalinks, the site logo/home link, and block-theme navigation keep the `/en/` prefix. WakaLang maintains the prefix only — it does not silently redirect to a different translation — and it leaves external links, anchors, `/wp-admin/`, REST, and feeds untouched.

= Can I migrate from Polylang or WPML? =

WakaLang does not include an automatic importer. You register your languages, then set each post's language and link translations into a group manually. Because WakaLang relies on WordPress's standard slugs and a small custom table, content stays in plain WordPress posts and terms.

== Screenshots ==

1. Languages screen for registering each language, locale, native name, URL prefix, and default language.
2. Settings screen for URL-prefix behavior, browser-language detection, and x-default hreflang output.
3. Front-end language switcher showing the active language and alternate language links on a prefixed page.
4. Language Switcher block available in the block editor and rendered by the same front-end switcher.

== Source Code ==

WakaLang ships as readable PHP; the only compiled asset is the block editor script.

* `assets/blocks/language-switcher/build/index.js` is the compiled Language Switcher block editor script. Its human-readable source ships in this plugin under `assets/blocks/language-switcher/src/` (`index.js`, `edit.js`, `block.json`).

To rebuild it, install Node.js, run `npm install`, then `npm run build:blocks` (which runs `@wordpress/scripts`). No other plugin code is minified or generated by a build tool.

== Changelog ==

= 0.1.0 =
* Language registry (option-backed) with an admin **Languages** screen: each language carries a code, locale, name, native name, URL prefix, default flag and enabled flag.
* URL-prefix rewrite routing (`/ja/…`, `/en/…`) — the prefix is the source of truth for the current language; rewrite rules flush on activation/deactivation.
* Current-language context service and public template functions (`wakalang_get_current_language()`, `wakalang_get_supported_languages()`, …), with optional root-request browser-language detection and a preferred-language cookie (both off-by-default-friendly and configurable).
* Settings screen for URL mode, fallback behaviour, hreflang, x-default, cookie/browser-detection toggles and uninstall data handling.
* Translation linking: a custom `wp_wakalang_translations` table and a post-editor meta box to set a post's language, link it into a translation group, see the other-language versions, and create a draft translation. Rows are removed when a post is permanently deleted; group changes fire the `wakalang_translation_group_updated` action.
* Translation repository served through the WordPress object cache (negative lookups cached, writes purge touched entries); `merge_groups()` folds one translation group into another, refused on a same-language collision.
* Language switcher via the `[wakalang_switcher]` shortcode, the `wakalang_language_switcher()` / `wakalang_get_language_switcher()` template functions, and an editor block. The current language renders as a non-link with `aria-current`; output passes through `wp_kses()`.
* Language switcher display options: a `flags` mode (`name` / `flag` / `flag_and_name`) rendering each language's flag as a Unicode emoji from its locale (no bundled images, no external requests), a global show/hide toggle, and automatic header (`wp_body_open`) or footer (`wp_footer`) placement.
* hreflang `<link rel="alternate" hreflang="…">` tags in `wp_head` for a page's language variants, plus an optional `x-default`. Filterable via `wakalang_hreflang_entries`.
* Language-preserving links: `post_link` / `page_link` / `post_type_link` / `term_link`, nav-menu item URLs, `home_url()` output, and block-theme/FSE navigation links keep the current language's URL prefix. External links, anchors, `mailto:`/`tel:`, `/wp-admin/`, REST and feeds are left untouched.
* Query language scoping: archive, search and feed (RSS/Atom) queries, plus the core `wp-sitemap.xml` (split per language), are filtered to the current language via shared `posts_clauses` / `terms_clauses` SQL with cache invalidation.
* Taxonomy translation: categories, tags and public custom taxonomy terms carry per-language name/slug and link into translation groups, with a term-editor field and a Translations column in term lists.
* SEO title and meta description per translation, stored in WakaLang-owned post meta and passed to WordPress core and the Yoast / Rank Math public filters (their own meta is never read or written).
* Per-language site title and tagline translation (overriding `option_blogname` / `option_blogdescription` on the front end without going through gettext).
* Admin locale follows the URL language via `determine_locale`.
* Admin post-list language filtering and an untranslated-coverage report on the Tools screen, alongside rewrite flush, relationship/orphan checks and settings export/import.
* Markdown Renderer for GitHub cooperation: WakaLang owns the site-wide language spine and suppresses GFMR's own switcher via its `gfmr_language_switcher_enabled` hook, avoiding a duplicate switcher.
* Extension API surface for add-ons (the `wakalang_loaded` action and the add-on registry) plus free-edition licensing stubs and a feature gate.
* Plugin bootstrap, activation/deactivation, uninstall handling, a privacy-policy suggestion, and full internationalization (bundled `.pot` + Japanese `.po`/`.mo` and block-editor JS translations).
