goldsky / lingua Goto Github PK
View Code? Open in Web Editor NEWMODX's Lexicon switcher for front-end interface
MODX's Lexicon switcher for front-end interface
When using the lingua.getValue snippet, data is not pulled from the default language. This bug affects not only instances when the selected translation isn't available, but instances where the default language is the one selected; in either case, lingua.getValue will return nothing.
This snippet should always return the value for the default language (i.e., the value from modx_site_content) if the translated value doesn't exist (i.e., the value from modx_lingua_site_content).
To get around this problem, I had to write the following wrapper snippet that I call instead of lingua.getValue:
// initialize
$vars = array(
'id'=>$id,
'field'=>$field
);
// get translated field
$field = $modx->runSnippet('lingua.getValue', $vars);
// if no translation, then get default
if (empty($field)) {
$field = $modx->runSnippet('getResourceField', $vars);
}
when setting richtext to off for a resource, it does work on first load (textarea for all languages).
After saving the resource,
richtext-editor shows up for other languages, than the first language.
First language is textarea like it should, but other languages (did only try with one additional language) have richtext-editor instaed of textarea.
@goldsky I'll handle this
Like the title says. Regardless of whether you are using a page ID or a full URL, Weblink resources do not work when Lingua is installed.
If MODX is installed in web root everything works fine.
However, if MODX is installed in a sub directory, when switching from the default language to another on a resource in the manager all the fields are blank.
I seem to be able to save and everything works on the web context if the fix is applied from the previous issue, but when you come back to the secondary language in the manager all the fields are blank. It seems to have trouble loading the values even though they are apparently saved.
I haven't tested TVs yet.
Hello @goldsky!
I found a little bug but very annoying. I had a problem with lingua.getValue snippet. It works great on it's own and get all TV's values well. But if used with getResources from inside a tpl Chunk it does not get (or output) the right value of Template Variables and uses the default value. And I have to notice that I took care of these two getResources options: &includeTVs=1
, &processTVs=1
And now my example:
This the line wich should display the right link to an image according to the language key:
<img src="[[lingua.getValue:default=
[[+art.image]]? &id=
[[+id]]&field=
art.image]]" />
But it doesn't work inside getResources. All standard fields language is switching right - content, pagetitle, etc.
Whats interesting from within this template:
<img src="[[lingua.getValue:default=
[[_art.image]]? &id=
[[_id]]&field=
art.image]]" />
it works great.
So I decided to look inside the snippet code, although I'm rather a poor backend developer :) And I did some experiments with lingua.getValue:
Original code:
// try TV else { $tv = $modx->getObject('modTemplateVar', array( 'name' => $field, )); if ($tv) { $linguaSiteTmplvarContentvalues = $modx->getObject('linguaSiteTmplvarContentvalues', array( 'lang_id' => $langObj->get('id'), 'tmplvarid' => $tv->get('id'), 'contentid' => $id, )); if ($linguaSiteTmplvarContentvalues) { $value = $linguaSiteTmplvarContentvalues->get('value'); $tv->setValue($tv->get('id'), $value); } $output = $tv->renderOutput($resource->get('id')); } }
And the code after makeovers:
// try TV else { $tv = $modx->getObject('modTemplateVar', array( 'name' => $field, )); if ($tv) { $linguaSiteTmplvarContentvalues = $modx->getObject('linguaSiteTmplvarContentvalues', array( 'lang_id' => $langObj->get('id'), 'tmplvarid' => $tv->get('id'), 'contentid' => $id, )); if ($linguaSiteTmplvarContentvalues) { $value = $linguaSiteTmplvarContentvalues->get('value'); // $tv->setValue($tv->get('id'), $value); } // $output = $tv->renderOutput($resource->get('id')); $output = $value; } }
I've just commented out two lines and instead of rendering the TV just outputing the found right value. And it started to work poroprerly. I'm not an expert so I hope you will improve the code. Meanwhile you can use this solution if anybody copes with the same problem.
Greetings
MODx 2.3.1, Articles extra installed, which is quite widespread for building blogs / news sections etc. No dropdown appears neither when editing articles container nor when editing an article item.
MODx features like TV etc are compatible with this plugin, so it's likely adding a small piece of code making Lingua plugin compatilbe with this.
It'll be appreciated a lot.
hi, i have a migx (this migx work only in web context) but dont show in backend a table grid, for other language, please help me
When the default language in the Modx-System-Settings are changed ("cultureKey", "fe_editor_lang"), the Lingua-translations in resources are messed up.
Probably the the content of the previous default language becomes the content of the new default language...
I would love for Lingua to be compatible with modmore ContentBlocks :)
https://www.modmore.com/extras/contentblocks/bugs/
Testing out Lingua for the first time.
Placed the selector snippet on the home resource to test.
Works fine until I go back to the manager which presents me with the login screen as soon as I try to load another manager page.
It only happens when I click on the language link in the selector drop down on the web context.
Modx 2.3.3
Any ideas what could be causing this?
Edit: I've tried deleting the cache and removing all cookies.
--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/9737839-lingua-selector-causing-manager-to-log-out?utm_campaign=plugin&utm_content=tracker%2F1919378&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F1919378&utm_medium=issues&utm_source=github).I use setPlaceholders package to get all the TVs from a common resources that shows up in header and footer. Same as the navigations using getResources. Whenever i change the language, those TVs displayed by getResources and setPlaceholders (TVs with [[+TVName]]) won't change to the selected language.
Would this plugin support the functionality a speak above?
Response will be greatly appreciated.
Thank you :)
After the initial import with ImportX the resources exist in the modx_site_content and in template variables tables because the default language values were included in the import.
At this point i'd like to update just the translated values in lingua tables but the newly imported resources don't exist there yet. They are only copied after a resource is edited in the manager and saved. I'm wondering if there's a way to make lingua pickup the newly imported resources in batch and insert them into its tables. At which point a simple sql update to add translated values into lingua tables can be done.
I have set up some Form Customization rules which include hiding / renaming some of the standard fields (description, introtext, link-attributes). Everything is fine on my standard language but when I switch to another language, all of the standard fields appear AND my custom renaming is gone.
One mor thing: when I rename a standard field, the flag is gone.
http://www.w3.org/International/questions/qa-i18n.en
Alias can be translated.
LINGUA is super, but I need to use the "collection" - and does not work properly - if you can do something about it?
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
Hi, ii set lingua.detect_browser system setting to Yes and made a try with few computers. Every time default language is loaded. How can I check what's wrong?
--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/4883604-detect-browser-language-doesn-t-work?utm_campaign=plugin&utm_content=tracker%2F1919378&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F1919378&utm_medium=issues&utm_source=github).Selecting tree node doesn't fit if the resource is hidden in a grid container, eg: Collection & GridClassKey
I have massive speed problems on my site when using the lingua.getValue snippet inside a pdoResources call, which is placed inside another pdoResources call.
As soon as I use something like this:
[[!lingua.getValue? &id=
[[+id]]&field=
myTvName]]
[[!lingua.getValue? &id=
[[+id]]&field=
pagetitle]]
my page loading time increases up to 13 seconds in average. When I delete the lingua.getValue snippet call from my pdoResources call, my page loading time is about 2.5 seconds.
Is there any faster way to get translated resources fields or TV's?
--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/30318147-speed-page-load-time-increases-by-using-getvalue?utm_campaign=plugin&utm_content=tracker%2F1919378&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F1919378&utm_medium=issues&utm_source=github).With Modx 2.3 on the CMP of Lingua the language settings (Locale name, flag, language code...) for a specific language is not possible. The Update-Window appears, but changed values are not saved. The following error is in the log:
[2014-07-19 11:58:00] (ERROR @ /assets/components/lingua/conn/mgr.php) Processor /var/www/chso-com/htdocs/www/core/components/lingua/processors/mgr/lang/update.php does not exist; Array
(
[processors_path] => /var/www/chso-com/htdocs/www/core/components/lingua/processors/
[location] =>
[action] => mgr/lang/update
)
Hi,
I got lingua working fine and i really like this approach of a lingual site.
But i have a problem when using getresources.
When i output the pagetitle in getresource's tpl, for example: [[+pagetitle]] it doesnt show the current language pagetitle.
Or maybe i'm just doing something wrong?
Thanks
Hi,
I have RichText TV with chunk call in it.
If i leave its lingua field empty or copy the same chunk call to it, next time i open resource (in manager) lingua field is populated with chunk content (html)?
TV cloning patterns is a bit hebrea for me, but is this related to it?
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
When using Lingua, link tags (e.g. [[~4]]) should be language-specific. As it is, the link tags always return the default link (i.e., the non-lingua uri data).
In the meantime, I had to create a custom snippet to use instead of the link tag... but that can get pretty unwieldy...
It would be great if you could add support for translatable chunks. Here's what I envision:
When you edit a chunk, you get the language dropdown just like when editing a resource. Chunks can then be referenced normally (as a single chunk), but it pulls the correct language version for that chunk.
There's a lot of static site-level (as opposed to page-level, e.g., TVs) content that needs to be translatable, too.
--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/6883125-translatable-chunks?utm_campaign=plugin&utm_content=tracker%2F1919378&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F1919378&utm_medium=issues&utm_source=github).(This kind of goes along with this issue which deals with delivering fields from the default language if translated fields aren't available.)
If using translatable TV fields, once you enter data there is no way to clear it out. In other words, empty TV fields will not save to the DB. One should be able to clear out TV fields without having to manually go into the database.
is imposible use [[!getImageList? &tvname=mp_enlaces
... &docid='99' ]] 99 is diferent to [[*id]] obtain
Is it possible to automatically detect browser language with Lingua?
We've had an issue reported by @sottwell about Lingua creating multiple instances of the Redactor content editor when languages are switched.
We were able to reproduce the issue in her dev cloud and noticed that it only seems to happen for German (two editors) and Italian (three editors).
--- There is a **[$15 open bounty](https://www.bountysource.com/issues/27178072-redactor-support?utm_campaign=plugin&utm_content=tracker%2F1919378&utm_medium=issues&utm_source=github)** on this issue. Add to the bounty at [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F1919378&utm_medium=issues&utm_source=github).Hello. Moved the site to a server version of PHP 5.4, get on the main page error when switching languages. On other pages all is well.
This is due to double-slash (address line). If the snippet to replace this line
on
$pageURL = $parseUrl['scheme'] . '://' . $parseUrl['host']. $parseUrl['path'];
error disappears.
By the way, on my server php 5.5, this error was not.
New problem after Lingua 2.0.2 update.
I found that the content editor in default language has now two windows to edit (two instances of CKEditor). Morover when switching to anorther languge, both CKEditor windows disappear. I suppose something is not working correctly.
After switching to english editor
Greetings
Add TV values to the output by initiating includeTV and processTV.
Currently there are 2 states that a language can be in: Active or Inactive. Practically speaking, there should be 3 states: Inactive, Active, and Published.
Translation and/or loading up of translations is not an instantaneous process. There should be a mechanism by which material can be worked on without it showing up on the front end incomplete.
--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/6890845-need-a-published-checkbox-setting-for-languages?utm_campaign=plugin&utm_content=tracker%2F1919378&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F1919378&utm_medium=issues&utm_source=github).I can not save TV's where the second language has an empty value. After saving and refreshing (Backend) I always get the value of my main language in my second language. Happens with imageTV's, MIGX TV's,...
Example: Main language is German, second language is English.
imageTV (DE selected): imagename-DE.jpg
imageTV (EN selected): imagename-EN.jpg
When I delete the file from the second language:
imageTV (DE selected): imagename-DE.jpg
imageTV (EN selected):
hit save and refresh the page, i get this:
imageTV (DE selected): imagename-DE.jpg
imageTV (EN selected): imagename-DE.jpg
When I add a TV of type MIGx lingua duplicate the field the same
When you add a TV-type MIGx, to lingua. The manager page show me 3 times in the TV in all languages(instead of 1 field in every language), and even when the information is filled in the 3 fields(duplicated), in the frontend does not see any value.
Here an image showing the problem:
I hope this can be solved.
Thanks in advance.
Hello. As I understand it, the table for version 2.1.0-beta3 should not be created.
https://github.com/goldsky/Lingua/blob/master/_build/lingua/resolvers/tables.resolver.php#L75
In the error log
[2015-02-22 11:19:22](ERROR @ /index.php) Error 42S02 executing statement:
Array
(
[0] => 42S02
[1] => 1146
[2] => Table 'sitename.modx_lingua_resource_scopes' doesn't exist
)
How can I fix it?
When switching a resource to "Static Resource", the content area is converted to a "Static Resource" file entry field. This field should be "translatable" in Lingua, i.e., one should be able to point the front end to different files (say, localized PDFs) based on language selection.
MODX saves the path to the source file in the content area of the site_content table, so it seems like it wouldn't be too hard to have Lingua do the same thing that it does with "Document" resources. In fact, you can get it mostly working now by doing the following:
THE CAVEAT: Even though doing the above will cause MODX to output the correct source file, the file name will always be from the default language URI, so you still can't get a localized file-name for your static resource.
I got Lingua working - it is great. However I have two questions/issues:
#1: I'm using it for two languages (English and German) and the lingua_selector displays sometimes "Select language" and sometimes "lingua.select_language"
#2: The language selector does something weird with pages which do not have an .html at the end
For issue #1: http://nde-consulting.com/dr.-johannes-vrana.html
For issue #2 (and #1): http://nde-consulting.com/
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
As someone building out a multi-site MODX install using a single manager with different contexts, it occurs to me that language activation needs to happen at the context level and not the global level. Some sites may have different sets of translations than others, and some may not have any at all.
To piggyback onto this feature request, the CMP for Lingua should probably be rewritten a bit. The current "Settings" tab should remain mostly unchanged except to rename the tab "Languages" and remove the "Active" setting. Then add a new tab: "Contexts" where you can assign languages to contexts and mark them as active or inactive.
If a language is assigned to a context, it can be selected in the editor for that context's resources. If it is marked as active then that translation will also be selectable on the front-end.
This would, of course, replace the lingua.contexts system setting.
If you want to get really fancy and replace the lingua.ids and lingua.parents settings, you could add two more tabs: "Resources" and "Parents" that allow you to assign languages to each respectively. I imagine, though, that that could get mighty tricky. Maybe on the "Contexts" tab, have a place where you can enter resource/parent IDs on the context to indicate specific resources that the settings (at the context level) should apply to. Kind of a hybrid of the current system and the new.
This Extra is already flipping amazing—and this would just be a nice-to-have, icing-on-the-cake feature—but I figured I would throw it up here anyway!
The built-in Auto-Tag TV type generates clickable tags based on all the entries of the template variable. The field itself translates just fine, but it would be extra-sweet if the clickable tags would also build out and be usable per-language (right now they only work for the default language).
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
I just ran across this bug that had me stumped—took me forever to even figure out what was causing the issue. I'm still not 100% sure that this isn't just something quirky with my build, but the fix won't break anything even if that's the case.
Behavior:
When a resource is set to Rich Text but you don't have a rich text editor installed, switching between languages gets really wonky. Some language content fields don't show up at all, and others are sized improperly.
Problem:
In the resource.js file if a resource is set as rich text, the js tests to see if MODx.ux.CKEditor is defined. However, MODx.ux is itself undefined—and since you can't test a property of "undefined", js kicks back an error causing the content field switching to fail in odd ways.
Solution:
Test MODx.ux before testing MODx.ux.CKEditor. In the resource.js file, replace lines 229–231 with the following:
if (typeof(MODx.ux) !== 'undefined') {
if (typeof(MODx.ux.CKEditor) !== 'undefined') {
MODx.ux.CKEditor.replaceComponent(this.getId());
}
}
Hi there
Firstly: Lingua ist awesome. :)
Second: We have some problems with alias path generation in frontend. In a test installation it didn't generate the alias for a resource in one language. And we weren't able to change it afterwards.
But a subsite of the said resource then had the correct alias path. And we could change it.
On a second note, it doesn't seem like lingua translates alias path when generating a url with [[~link]]. Is there a way to provide that?
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
Works fine on the default language but won't save the content field for the second language.
It says it saves and doesn't put any errors in the MODX log or in firebug.
But if I refresh the page the content for the second language isn't showing anymore so it's not getting stored.
The work-around is to disable rich text for the resource, input the content and save it, then enable rich text again.
Any ideas?
--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/27915268-tinymce-rte-not-working-with-lingua?utm_campaign=plugin&utm_content=tracker%2F1919378&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F1919378&utm_medium=issues&utm_source=github).To avoid overriding on upgrade.
When using contexts for different/separate websites its important that each individual site can have its own set of active languages. Sometimes not all sites share the same set of languages.
Sorting languages order would be a good feature.
--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/4165563-language-sorting?utm_campaign=plugin&utm_content=tracker%2F1919378&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F1919378&utm_medium=issues&utm_source=github).A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.