Giter Club home page Giter Club logo

nlingual's Introduction

nLingual

The nLingual system allows for flexible multilingual support and translation management for WordPress. The system handles translations on a per-post basis, and can be set to be synchronized so changes to certain details on one are copied to the others. It offers you control over what can be translated and how, with a number of utilities available for 3rd party themes and plugins to utilize.

nLingual 2 offers more robust control of translation management, better extensibility, and fixes to numerous core issues with the previous incarnation.

Translation for Almost Anything

When setting up, you have control over what content supports translation. Any UI-enabled post types or taxonomies will be available for enabling, along with any navigation menus or sidebar locations registered. In addition, nLingual includes a LocalizeThis API that can be enabled on nearly any text field found in the admin, allowing just about any option or meta field to support separate values in each language.

Simple Translation Creation and Management

Assigning a language and translations to a post can be done on either the post editor screen or the posts management screen via Quick Edit (language can also be set for multiple post via Bulk Edit). You can also easily create new translations for existing posts on the fly; select "New [language] [post type]", provide a translated title if you wish, and a new draft post will be created that is an exact copy of the original, ready for translation.

Translations are stored as independent posts, associated with their counterparts via a custom table. This allows you to translate the custom fields and other metadata associated with a post, and can assign them their own separate terms if desired. However, since there are plenty of occasions where you want the same information used between posts, nLingual offers post synchronization.

Post Synchronization

Each post type has it's own rules for what data is synchronized between translations. When changes are saved to a post, it's translations will be updated with to have the same data in the approved fields. This covers post data (e.g. date, status, and menu order), terms of specified taxonomies, and any meta fields you specify (e.g. the thumbnail image used, or a custom field value).

Note: Currently, there is no per-post basis override for the synchronization rules

Free-form Language Management

Admittedly, this is a feature few will need, but it's a godsend to those that do. When setting up the languages nLingual will use, you can define you own languages from scratch or based on numerous presets. Each language has a number of fields:

  • System Name: the name to use when referring to the language within the admin.
  • Native Name: the name of the language as it appears to native speakers on the site.
  • Short Name: a shorthand version of the native name, if applicable.
  • Locale: the language/country code to represent this language, as well identify the .mo file to load for text domains.
  • ISO Code: the official ISO 639-1 code for the language (2 letters)
  • Slug: the value to use when localizing a URL for the language (typically the same as the ISO code).
  • Text Direction: the text direction the language should be rendered in (Left-to-right or right-to-left). Will override the one specified in the text domain files.
  • Active State: wether or not to allow public access to content in the language.

Flexible Language Detection/Switching

When the public-facing side of the site is loaded, nLingual will attempt to detect what language to serve the page in, using the following process:

  1. Use the language code in the $_REQUEST array for the specified key, if present.
  2. Use the language code in either the subdomain or directory path, depending on method specified.
  3. Use the browser's preferred language setting and find the closest match, falling back to the default language.

Once the language is set, it can be overridden by the language belonging to the requested post. This override is an configurable option.

In addition, the language can temporarily be switched to another by 3rd party theme or plugin code, similar to switching blogs in a multisite installation. When the language is switched, all text domain files will be reloaded in the desired language (the originals cached for when it's restored), so any gettext translations will reflect the current language.

Extensibility and 3rd Party Development

In addition to numerous hooks to modify the functionality of nLingual, this plugin also includes some useful gettext utilities: _f, _ef, _fx, _efx, _a, and _xa, all of which are documented in includes/functions-gettext.php.

Backwards Compatibility

Although nLingual 2 has be rewritten from scratch, most if not all of the functions and filters are still available via the backwards compatibility feature, which is automatically enabled upon upgrading. However, any code that directly queries the database using the old nLingual language and translation tables will need to be updated to reflect the new structure.

nlingual's People

Contributors

dougwollison avatar lovor01 avatar olumby avatar orthographic-pedant avatar veroniqueaubry avatar vianney avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

nlingual's Issues

Breaks menus with Hueman theme

As the title says, activating the plugin breaks the menu's, at least in my case. I have the Hueman theme installed and when I activate the plugin my menu bar simply disappears. I tried creating a new menu, assigning it to all possible menu places, but nothing appears. Sth to look in to.

Function undefined error

$url = get_author_posts_link( get_queried_object_id() );

I'm seeing undefined function fatal errors in my logs for the above line.

I believe that should be get_the_author_posts_link, with the the. I'd make a PR but it's so small a change that any workflow disruption (for you) of the PR flow seems not worth the hassle. If you'd prefer a PR, I can do that, no problem.

Original proposal for the relevant function in WP, named as in line 452 but, apparently, modified after some comments

Function docs

Default language works only for English

Hi
I try to use Persian and English language for my WordPress. I want to set Persian as default and English as a second language.
So I added two languages and activated Skip Localization for Default Language option in the admin panel. Then I changed Permalink to Plain and seated it back to Post name.
Now, when I open my website, it redirects to /en/ while I put Persian as default, and I was active skip localization for the default language. But when it sets on English as the default language, everything works normally.

Plugin version: 2.9.1.2
Wordpress: 5.8.1

Settings conflict prevents automatic language redirection

Checking "URLs for the default language will be unmodified" prevents redirection to user agent's preferred language. Unchecking it causes redirection to start working, but of course means the default language also gets redirected. Fiddling with other maybe-relevant settings like "Should the language of the requested post take precedence in the event of a language mismatch?" doesn't fix the behavior.

I've reproduced this in a basic docker-compose set-up of Wordpress with just nLingual installed, by creating a translation of the initial "Hello world!" post, getting redirection from the home page to work when my browser language is set to that of the translation, then breaking redirection by checking the "URLs for the default language will be unmodified" box.

This seems like a bug to me in that it's preventing functionality I both wanted and expected, given the settings I'd chosen, to work, but is that the case, or is it in fact working as intended?

Option to link existing translation

Hi,
your plugin is really great. The only thing I've not found is an option to link two already existing translation.
Exampe: I've a post with an id 1 in german and the same post was translated into english with an id 3. How can I group this two posts? The same with reusable blocks, terms and taxonomies.

At the moment I make this directly in database table.

Kind regards and many thanks for this plugin. It seems to be a really good aleternative to polylang.

Multi-page post are broken

Create a post with multiple pages using the page break block. Only the first page of this post is now accessible, the rest loops back to the first page.

Some page URL lookups behaving strangely

Version: 2.9.0

Situation:
Site uses a page as its homepage (the URL of which is typically retrievable with get_option('page_on_front')). This happens to be named "desktop", in this case. Without nLingual, and under nLingual 2.8.10, this resolves simply to example.com/ with no page slug. Under nLingual, the home page is redirected to example.com/desktop/, and get_option('page_on_front') not only returns that desktop/ path while on the homepage, but proceeds to return whatever the current page is, as one nagivates around the site, such that a link that would normally always point at the homepage (simply, example.com/) points instead to, say, example.com/some-page while visiting some-page.

So there seem to be two things going on, that are different from behavior under vanilla WP or nLingual 2.8.10:

  1. A page that normally serves as the front-page, is now explicitly redirected to when one visits the home page (load example.com, end up on example.com/desktop)
  2. WordPress is unable to locate the home page URL via the page_on_front option, and ends up providing the current page path for some reason.

The first is just undesirable, but the second actually breaks things.

Possibly relatedly, I'm also seeing page URL lookups built into WooCommerce, for things like the cart or checkout URLs, return a link to the site root instead, with the result that these links are non-functional with nLingual 2.9.0 enabled. There seems generally to be something odd happening with internal WordPress page URL lookups, though not with lookups for the purposes of request routing, as far as I can tell (if you put the URLs in manually, they work).

(It may be premature to report bugs in 2.9.0 since it's not up on the plugin market yet, but given the version bump on master I thought it safe to at least try out; if you already knew or suspected it has issues of this sort and aren't ready for anyone to be messing with it, I'll take no offense at a fast close on this issue)

author archive url gets mangled

hi great little plugin, but I've encountered a bug: the author archive url gets mangled when nLinugal is active.

Tested with fresh wp 5.8 and Twenty twenty theme, and with nLingual master at 7fbe5fd

How to reproduce:

  1. just install the plugin, with all default settings.

  2. go to the author archive page.

  3. this results in a 404, and the url is something like: the following: (where base url is example.com, author slug is demo_author)

     https://example.com/a href=https:/example.com/author/demo_author/ title=Posts by demo_author rel=authordemo_author/a
    

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.