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.
Related
I have spent hours searching to find where magento stores full county name.
We can get a full list of countries using this code:
$_countries = Mage::getResourceModel('directory/country_collection')
->loadData()
->toOptionArray(false);
This will return an array with country code and name, I investigated the directory module, and found out this call gets data from the table
directory_county
But this table don't have full county name! So where is it stored?
and how is it retrieved using that call?
Thanks in advance.
Ok so to compensate for my wrong answer. Here is how this works:
/lib/Zend/Locale/Data/en.xml - if your store is in english, else another xml in the same directoery is read. Every country is there and its code under the xml tag <territory>
The xml is cached using the Zend_Cache_Core class.
/lib/Zend/Locale.php - function getTranslation invokes the lib/Zend/Cache/Core.php class
to load from the cache.
Example: If you change the name of some country in en.xml and clear the magento cache. You will see the change when u invoke your code again.
Full country names are not stored in database. Magento uses inbuilt Zend functionality.
Check file: lib/Zend/Locale/Data/Translation.php for full list.
Use the Zend_Local translation.
<?php
$code = 'EN';
echo Mage::app()->getLocale()->getTranslation($code, 'Territory', null, 2);
?>
Use the column 'iso2_code' from the table 'directory_country' for your $code.
Magneto only stores country codes in DB, and relies for names on Zend's Locale module to provide translated names, for different locale.
By the toOptionArray method it invokes the Zend_Locale class to get the translated value.
Refer $name = Mage::app()->getLocale()->getCountryTranslation($data['value']);, which gets to Mage_Core_Model_Locale and then to Zend_Locale.
It decides which of the node from the data to read, by the switch case statement in Zend_Locale_Data::getContent() line# 962, 963
Magento caches the names, so if you make any change to XML files, make sure to clean your cache folder to get what you seek.
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']
);
}
}
[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');
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
I was used to putting id's in the URL to map to an item in the database:
/hotels/1
but what if I want to get the name of the hotel with an id of 1 and put it in the URL and replace spaces with hyphens?
/hotels/hotel-bianca
I am using Kohana and there is the concept of routing (which is pretty much present in all MVC frameworks), but I can't seem to get it working
How do I go about doing this?
Since I know nothing about kohana, I am going to present a possible PHP answer.
Could you pass the id through the URL and request it with PHP, and if you're passing the name of the hotel, have that correspond to the item in the database with the hotel-name as its field?
For this purpose I use special field in db table named url :)
So for example /controller/open/urladress will look for url field with 'urladress' inside to open :D
I don't think you can change uri on fly)
In the controller you could search the database for the name. I am used to Kohana 2.3.4 with ORM so this is how I would do it:
// first you need to replace all hyphens with spaces
$name = str_replace('-', ' ', $parameter);
// search your db for the hotel by name
$hotel = ORM::factory('hotel')->where('name', $name)->find();
// check to make sure it is loaded
if ( ! $hotel->loaded)
{
// Do something i.e. 404 page or let them know it wasn't found
}
This would let you specify by name. You could also add a check to see if the parameter was integer or not and search by id if it was.