[Joomla->2.3.2 Virtuemart 2.1]
Hello everybody I am currently developing a fast webservice webapp to connect to joomla and virtuemart and insert a product.
I am having difficulties with multilanguage.
I send a product array as following:
$product['vmlang'] = 'en-GB';
$product['product_name'] = 'Red shirt';
$product['product_description'] = 'Red shirt very nice';
..............
And then I want to translate in italian so I change and pass:
$product['vmlang'] = 'it-IT';
$product['product_name'] = 'Maglia Rossa';
$product['product_description'] = 'Maglia Rossa molto carina';
..............
But it doesn't work: it overwrites the first values in table #_virtuemart_product_en_gb instead of inserting new fields in #_virtuemart_product_it_it
Looking at workflow from joomla panel, it seems first change the JApplication and virtuemart language and then do vmModel('product')->store() with the new language.
From backend the VirtuemartControllerTranslate is called with ->paste task but it doesn't seems to change the app language.
Which can be the problem?
Thanks
I answer by my self
you should put following to change language. hope this help
$b= VmConfig::set('vmlang','en_gb');
Related
SilverStripe: v4
Module used: https://github.com/unclecheese/silverstripe-display-logic
Hello and good day!
I'm in the Security page (Lists of Members) and was trying to display a ListboxField upon a certain string or value is found on another ListboxField.
.
With The image above, I wanted to select or input in the Groups field the Sales Representative role, and once the Sales Representative is present in the Groups, that's the moment I shall display another field
Here's my code snippet
$codesList = Member::get()->column('Code');
$codes = ListboxField::create(
'AccountPurchases',
'Account Purchases',
$codesList);
$fields->insertAfter('DirectGroups', $codes);
$codes->displayIf("DirectGroups")->contains("Sales Representative");
But the problem is, no matter what I did (1: dev/build?flush=1, 2: refresh the page, 3: restart the app) the desired field named $codes still won't appear.
But if I'm applying it to a normal field like the FirstName (which is a simple TextField), it's working perfectly fine...
$codesList = Member::get()->column('Code');
$codes = ListboxField::create(
'AccountPurchases',
'Account Purchases',
$codesList);
$fields->insertAfter('DirectGroups', $codes);
$codes->displayIf("FirstName")->contains("Sales Representative");
Any ideas how to perform my desired output?
For non-standard form fields, you'll need to use the display-logic wrapper. https://github.com/unclecheese/silverstripe-display-logic#dealing-with-non-standard-form-fields
The definition of "non-standard" is a bit hard to find, but in my experience it's anything non-plain-html-input. Listbox is a fancy front-end thing, so it qualifies. The examples in the docs can be confusing, but if you are using SS4 and the latest display-logic, then use Wrapper::create instead of DisplayLogicWrapper::create. If you wrap it, it should work.
$codesList = Member::get()->column('Code');
$codes = Wrapper::create(
ListboxField::create('AccountPurchases','Account Purchases',$codesList);
)->displayIf("DirectGroups")->contains("Sales Representative")->end();
$fields->insertAfter('DirectGroups', $codes);
I created a custom page in Open Cart and I'm kind of pulling my hair out here. What I want to do is simple: Fetch the currently selected language(possibly from the header?). I am using Opencart version 2.0.x. I am new to php and it's not my system so I'm having a really hard time figuring this out. I have tried the following code:
$lang = $this->language->get('code');
and it returns nothing. Would really appreciate the help!
Both these codes returns my language code, en:
echo $this->language->get('code');
echo $this->session->data['language'];
I'm using opencart version 1.5.5.1. We've a website coded using opencart framework. The site uses opencart multi-store feature also. All stores use English language.
Now the question is, is it possible to use different language labels for different stores?
For example: One store is related to sports items and another one is related to wrist watches. So we need to use language labels related to sports items in one store and language labels related to watches for the other one.
I'm not sure whether it's possible or not, as in opencart we load the language files via controller file of each module.
Please help me.
Thanks in advance!
Not sure if this is the most elegant way, but here's a hack that first came to mind:
Create multiple languages in Admin, i.e. English_sports, English_watches, French_sports etc.
in catalog/comtroller/module/language.php add a conditional statement to catch and filter out not needed languages:
Find line 32:
$results = $this->model_localisation_language->getLanguages();
Add:
$store_id = $this->config->get('config_store_id');
Inside data population loop add your conditional and string cleaning code:
foreach ($results as $result) {
if ($store_id == "0" && $result['name'] == 'English_sports'){continue;}
$strings = array("_sports","_watches");
if ($result['status']) {
$this->data['languages'][] = array(
//clean name strings for output
'name' => str_replace($strings,'',$result['name']),
'code' => $result['code'],
'image' => $result['image']
);
}
}
i have an issue that is going to destroy my mind ... i am not a PHP developer so i can not find any way to solve it...
I am using K2 (v 2.6.2 updated from 2.5.7) for CCK (with alotof custom templates) and Joomfish (2.1.7) deployed on a Joomla 1.5.26 installation.
I was using the following code (in my templates) in order to fetch my individual k2 extra fields by name (K2 2.5.7):
$extraFld = array();
if ( $this->item->extra_fields ) {
foreach ( $this->item->extra_fields as $key=>$extraField ) {
$extraFld[ $extraField->name ] = $extraField->value;
}
}
and then i was fetching it like this:
echo "<li class=\"dinning-cuisine\"><span>" . JText::_('Cuisine') . "</span><br />" . $extraFld['Cuisine'] . "</li>\n";
But since version 2.6.2 there is the option to directly fetch an extra field name & val:
$this->item-extraFields->ALIASNAME->name
$this->item-extraFields->ALIASNAME->value
as described in K2 2.6.2 What is new documentation.
The problem is the following:
I have a bi-lingual site in Greek (default) and English locales.
I create an extra field in Default locale "Πεδίο 1" with alias name 'field1'
If i try to translate it the only option i have is to translate its name to lets say 'Extra Field 1' (different than its alias) ...
Then in my custom template if i try to fetch it like:
$this->item->extraFields->field1->value
only the Greek locale works. In English locale i receive a NULL value!
Any relevant experiences and solutions ?
Try doing this:
String:
JText::_('CUISINE') //should always be Capital letters
Translation (language file):
CUISINE=Cuisine
I'm not sure which file you are using to translate the string, however seeing as you are adding this code to your template index.php, add the translation string to en-GB.tpl_tamplatename.ini
After quite alot of tests i think that in a multilingual web site, retrieving individual extra field values using their alias name does not work. At least not for Joomla 1.5 ...
The code supposed to be working is:
$this->item-extraFields->ALIASNAME->value
I have a web site with default language 'Greek' and secondary language 'English'.
I have an extra field named in Greek 'Πεδίο 1' with Alias 'field1'.
I have translated this extra field (using Joomfish) in English to 'Field 1'...
If i try to fetch its value using:
$this->item-extraFields->field1->value
the code is working only for default language 'Greek' BUT NOT for English.
I have managed to make my URL i18n compliant using Zend_Controller_Router.
Ie:
en/user/login becomes fr/utilisateur/connexion and both URLs go to the same controller/action.
The problem I am facing is the following
I have a language switcher that is displayed as follow :
Français
English
Italiano
etc.
The currently active language doesn't have an anchor tag, but all others do.
For the languages that have an anchor on them I am building the URL and I want them to be translated in their specific languages.
Currently if I am in French all the urls get builded in french, even if I set the #local key as a param in the URL view helper (tried "#locale" => 'en', "#locale" => new Zend_Locale('en'))
en/utilisateur/connexion
it/utilisateur/connexion
instead of
en/user/login
it/utente/collegamento
because the locale used while building the URL is the one that is defined application wide.
EDIT
I digged a bit deeper in my issue an I found that only the current locale add its resources loaded, which mean I can't get route in the proper language for the route to be built in the right language
My new issue is : how do I load multiple language translation resources?
(I am planning to implement cache in the far future (near release), so I might get better performances)
Hope this helps re the new issue.
"My new issue is : how do I load multiple language translation resources?"
Just a quick caveat to say I didn't write the code below, it was taken from a example app put together by the guys at Zend however it might help to have it broken down like this.
Their approach for the example app was using a csv file containing translations and using your config file (the default one in a new project being application.ini) to specify the path to all your language translation resources.
like this:
;; Languages
language.file.en = APPLICATION_PATH "/../language/en/translate.csv"
language.file.fr = APPLICATION_PATH "/../language/fr/translate.csv"
language.file.de = APPLICATION_PATH "/../language/de/translate.csv"
language.file.es = APPLICATION_PATH "/../language/es/translate.csv"
language.name.zz = Language
language.name.en = English
language.name.fr = Français
language.name.de = Deutsche
language.name.es = Español
And in each csv file, if you are using something like Excel or Open Office to create it, column A would be the original language and column B the translation.
As an example where English is the original language and a Spanish translation is required:
A B
login entrar
logout salir
You could do that for all the words/phrases you want to translate.
If a translation isn't found then the default original word is used.
Your main application bootstrap could have something like this:
protected function _initLanguage()
{
$options = $this->getOptions();
Zend_Registry::set('language',$options['language']);
$langSess = new Zend_Session_Namespace('language');
if (!isset($langSess->translate)) {
$translate = new Zend_Translate('csv', $options['language']['file']['en']);
$langSess->translate = $translate;
}
if (!isset($langSess->locale)) {
$langSess->locale = 'en';
}
Zend_Locale::setDefault($langSess->locale);
}
As the translate object is held in the session you can use it in any of your views etc using something like:
$langSess = new Zend_Session_Namespace('language');
$translate = $langSess->translate;
and:
<?php echo $translate->_('login') ?>
where you want something to be translated on selecting an alternative language. In the example above the word login would appear when English is selected and entrar when Spanish is selected.
There's loads more to Zend_Translate than this and several ways to implement it so I'm not saying this is the best way by any means.
If it helps or if I can give you more info let me know.
Cheers,
Dave