Codeigniter Arabic language and rtl (right to left) stylesheet - codeigniter

I have a bilingual site, English and Arabic. Default language is Arabic and default loaded style.css is rtl. I switch the language with session and the translated text from language folder works correctly.
But for the second language (English) I have some issues:
When I am in About page and I switch language is goes to main page . How I can redirect to same page where I've been before switching language.
My function to switch language is:
public function change($type){
$this->session->set_userdata('lang', $type);
redirect(base_url());
}
After switching the language I need that also the stle.css for English language gets loaded.

In order to send the user to the same page between languages, you need to check which page the user is browsing, before invoking your function change($type)
You can get the current link like this:
$current_url = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
the redirect depends how your multi-language site is designed. It could be:
yoursite.com/ar
yoursite.com/en
or
en.yoursite.com
ar.yoursite.com
anyway basically you'll need to replace en with ar
the css change is easy to perform, just make use of the session you have created just before the redirect:
in the view file where you load the css, load the version depending on the session value of lang, make sure you use the default css, in case there is no session set (yet).

Related

TYPO3 create links and respect language of target page (Fluid, typolink)

we have a webpage, where not all pages are translated. So many pages are only available in english and some special pages (country landing pages) are translated to various languages.
From these special translated pages I want to create links automatically converted to the default languages if the target page is not translated.
In menus (HMENU) "protectLvar = 1" works fine for me.
But how can I achieve this in normal typolinks or fluid "<f:link.page uid="..."> without manually dealing with the language ?
I'm on typo3 9.5.
Sample:
I have the following polish URL:
mydomain.com/pl/poland/
All the links from this page should go to "/en/subpage-xy/" because the above page is the only page translated to "pl". But actually all links go to "/pl/subpage-xy/" regardless if pages are translated to "pl".
The content-fallback mode leads to displaying english content under a /pl/-URL. I don`t want to change the fallback mode - I only want the links to be created to available language of the target page.
Is this possible ? Many thanks for any hints.
I think that you can't achieve what you want with default behavior.
I suggest you to wrote your own view helper based on <f:link.page> and in that view helper, you can check with a request in the DB if the page exist for the current language and switch to English if that's not the case.
I guess that you can also generate the link with typoscript with condition over page existence in current language but it's more tricky.
You have a sample here : check if current page is translated

Magento translate file

I am want translate magento. I am true translate some string in \app\locale\en_US, but I am not see result in admin panel. Why magento not show changed value in en_US folder. I am rename en_US folder but my site work with english. Why? I want copy \app\locale\en_US to \app\locale\my_lang translate. How I can do it, this folder with new translate work to my site. If I am translate all \app\locale\my_lang how I can add to site. And how I can see change during translate..
Have you selectect the right locale in admin (from footer of the page)?
If your translations are for a custom module ensure that you have defined the translation declarations in the etc/config.xml (frontend and/or adminhtml areas), otherwise ensure that you have modified the right module's translation file (eg if you have a string 'my string' that is present in Mage_Customer.csv and in Mage_Catalog.csv you must ensure that you have modified the proper one that is used where you want to see the result).
Also note that you can modify translations in app/design/package/theme folder...in a translate.csv called file.
The reason you see texts in english even if you delete translations folder is that they are by default passed in code through __() function in english. Magento checks if it finds the translation for the current locale in app/locale/ if it does it shows you that value, otherwise the original string passed to __() function is shown.

swapping rails3 layout on the fly

I have am trying to dig into twitter bootstrap and rails3 sites that actually look and function well (new to it all). I have this feature I want where I have a twitter bootstrap navigation (specified in what I guess is the default application layout) that calls a _navigation.erb.html etc. This works great, but on that navigation i want a "Se Habla Espanol" or what not, where when the user clicks there, the navigation text all changes to spanish. i thought easiest would be have another _navigationespanol.erb.html or something that changes the navigation words all around and also when click (toggling into spanish mode) it sets all the text in the pages to spanish by anytime there is a text render or whatever a variable flag was set and is interrogated on page index render show or what have you and it renders spanish or english words...
So ideally click on see it all in spanish, it loads a new layout (my main question) that has the spanish navigation and messages and other twitter bootstrap stuff and it also sets a global var i can look at in other renders to see if im rendering english or spanish.
More than swapping layouts, it seems that you need to implement Internationalization (I18n). In such case you'll have to create an directory config/locales that holds a .yaml file for each of the language you're trying to have translation for, for instance:
# on a file called en.yml
en:
hello: "Hello world"
For a complete guide on how to go about it: Rails Internationalization (I18n) API

How can I preview Virtuemart2 Order verification email layout changes?

I am trying to change the layout ( css/html structure) of Virtuemart 2 order verification emails. Problem is that I have to make a fake purchase each and every time I do a change in the 10 different files (located # components/com_virtuemart/views/invoice/order/tmpl) that create this email template.
The closest "preview" I got was this direct access url "http://domain.com/index.php?option=com_virtuemart&view=invoice&layout=invoice&format=html&tmpl=component&virtuemart_order_id=1401"
But again it loads Joomla's head/body elements not the actual email template.
So how can I have a "preview" of how the template looks like with my new changes BEFORE make an actual test purchase? Is this possible?
You shouldn't change the core files otherwise the next update of VirtueMart (of which there are many) will erase your changes.
You should use Joomla!'s template overrides which VM2 supports that way you can update as needed to new versions without loosing your changes. See this article on docs.joomla.org on "How to override the output from the Joomla! core" and this one on template overrides.
3. You need to add the &format=raw at the end of the link to retrieve just the output of the component with out the template/html body wrapped around it. Of course that relies on the component as well.
I was going to suggest using raw, but looking at the current VM2 it doesn't properly support the format=raw option. Looking at the mail layout in the invoice view it not structured to return it the way you expect, it actually generates a HTML version by default with a matching text only version.
The best I could come up given those two options
Return a close equivalent of the HTML email
http://domain.com/index.php?option=com_virtuemart&view=invoice&layout=mail&virtuemart_order_id=1401&tmpl=component
Return the text version, albeit wrapped in the html page... you may have to view the source to see your invoice text.
http://shop.craigphillips.biz/index.php?option=com_virtuemart&view=invoice&layout=mail_raw&virtuemart_order_id=4&tmpl=component

codeigniter load language add whitespace

I am developing a multilingual site and using sessions to change language, my issue is when I load a language it is adding a white space on top of page, I tried this ways:
In constructor:
function __construct(){
parent::__construct();
$this->lang->load('main', $this->session->userdata('language'));
}
top body it adds a white-space
When I check in "view source" it does not display any white space but in firebug i can see:
I also tried to load lang in controller and view but it has same effect.
Edit: I noticed it is only adding space to languages other then English. In English it works fine.
Thanks for any support.
It was adding a character at top of language file, This solved my issue http://studentguru.gr/b/solidus/archive/2009/12/30/lt-php-include-gt-strange-extra-white-space-at-the-beginning-of-page.aspx

Resources