-
Notifications
You must be signed in to change notification settings - Fork 7
nLingual 2 Compatibility Checklist
Although there has been a concerted effort to provide ample backwards compatibility to systems using nLingual 1, there are still some potential issues that will need to be addressed, mostly regarding custom code that uses the nLingual API.
Guaranteed, any custom SQL that involves the old nLingual tables will need rewriting. Unfortunately there was no feasible way to add backwards compatibility for this, but ideally, this won't take much work for patching your code.
First, the languages table is gone, as it should never have been a table in the first place; you can access languages via nLingual\Registry::languages()
. If you for whatever reason have queries that access the languages table, you'll have to rewrite them (if you're just using the join to match posts by language slug, you should be able to drop the join and search by language_id
you can get from nLingual\Registry::languages()->get($slug)
).
Second, any queries that access the translations table will need some minor rewriting. The lang_id
column is now language_id
, and post_id
is now object_id
(you'll need to specify the object_type
too). Those column changes should be painless, and as for your JOIN clause, updating it from e.g. ($wpdb->nL_translations.post_id = wp_posts.ID)
to ($wpdb->nl_translations.object_id = $wpdb->posts.ID AND $wpdb->nl_translations.object_type = 'post')
should do the job. I've updated my own code this way and can vouch that it works.
The following functions are accessible via the compatibility feature (enabled automatically if it detects you previously used nLingual 1):
nL_get_option()
nL_default_lang()
nL_current_lang()
nL_is_lang()
nL_is_default()
nL_query_var()
nL_get_post_lang()
nL_get_translation()
nL_associated_posts()
nL_get_lang()
nL_lang_id()
nL_lang_slug()
nL_get_lang_links()
nL_print_lang_links()
nL_split_langs()
nLingual_get_curlang_version()
If you're using functions not on this list, you'll have to update your code to the appropriate method within the Registry
, Translator
, Rewriter
or whatever class houses the functionality you need.
The filters have been renamed to lowercase, but the Liason
class adds hooks to these that will run any callbacks on the old hooks. The one exception is the old 'nLingual_localize_here'
filter, who's new version is used in a different context (on the result of Rewriter::localize_here()
, similar to the old 'nLingual_localize_here_array'
). You'll need to modify your code to take this into account.
The URL rewrite/redirect methods have been altered. If your site uses permalinks, you can choose path or domain prefix. The query string option has been removed and will only be usable if your site doesn't use permalinks. This is mostly due to the unreliable way to add the necessary ?lang=en
to URLs since some generate it before or after adding the trailing slash. Even if you set the method to query string ("get"), the system will auto-correct it to path prefix if it detects permalinks are enabled (and vice-versa).
Full documentation of the new filters and methods are in progress, but everything is well documented within the code itself via the PHPDoc blocks.