Zend_Translate class and space character - php

I am using Zend_Translate with ini adapter in my project.
I want to know how it is possible to use space character in my ini file.
Sample:
ini file:
Show All = my translation // there is space between Show & All
view scipt:
echo $this->translate('Show All') // it doesnt translate

You can't ( atleast i don't know a way ) , but you got it a bit wrong , think of the first parameter ( "Show All" ) as a constant or a variable , witch has some content that will changed in certan scenarios . For example i would use $this->translate("SHOW_ALL"); .

Related

Is using echo rather than printf a trouble maker for string translation using .pot file and Poedit?

I was wondering could the use of echo in php code rather than the use of printf() be the cause of a .mo file or in general the reason why the translation files do not work at all?
For Example:
In my php code I have this line of code:
echo __('Twinkle Twinkle little star');
Which has the double underscore identifier __().
When using Poedit, I get my string displayed in the translatable strings column, so that's not an issue.
Sum up:
Could echo cause a problem with the translation even thought Poedit can index and understand that the string is there?
Thanks in advance for your time.
echo and printf are not related to translations. They are merely ways to output a string.
The translating is performed by the __() function. So assuming you have your locale set to French with the proper files loaded:
echo "Hello";
// Hello
echo __("Hello");
// Bonjour
printf("Hello");
// Hello
printf(__("Hello"));
// Bonjour

traduction gettext with codeigniter

I 'm from peru present .
what happens is that eh followed a tutorial on gettext and CodeIgniter and I can not get it to work , I only translates the text into Spanish peru .
the only thing that changed was the helper eh , that after writing the function , execute it as follows . set_translation_language ( en_EU ) , or where I have to run this function . ?
From already thank you very much.
I suggest you to take a look at this: http://www.codeigniter.com/userguide2/libraries/language.html
CodeIgniter already support multi-language (location).
If your site will support only one language (Spanish), there is no need to use a location service.
But if you plan to support English and Spanish for example, what you need to do is:
Create a folder with the language name (ie: English)
Add a file with "_lang.php" (no quotes) at the end (ie: text_lang.php)
Create an array under the value $lang, each object inside will contain the
key, for example: $lang['title'] = "This is the title."; (English)
and then on the Spanish folder, the same but translated:
$lang['title'] = "Este es el título.";
Load the language file: $this->lang->load('text_lang', 'spanish'); that's valid in our example.
Last, but not least, load the language line you want to translate, for example, title $this->lang->line('title');

getCsvControl() always returns same delimiter - PHP

$file = new SplFileObject('D:\BackUp\addressbook.csv');
print_r($file->getCsvControl());
What i am trying to do is find the delimiter of a csv file using php. the addressbook.csv file looks like
"id";"firstname";"lastname";"phone";"email"
"1";"jishan";"ishrak";"17878";"jishan.ishrak#gmail.com"
and another file is addressbook1.csv which is like
"id","firstname","lastname","phone","email"
"1","jishan","ishrak","17878","jishan.ishrak#gmail.com"
one is separated by "," and another one is with ";" but the function
getCsvControl()
always returns an array like
Array ( [0] => , [1] => " )
I mean in the [0] index it always gives "," for both files
is there a way to solve this issue.
This is not a bug. SplFileObject::getCsvControl() is never intended to detect the delimiter from a CSV file. It returns only the default control characters or the one previously set with SplFileObject::setCsvControl(). And this set CSV control characters are used, if is nothing handed over in the SplFileObject::fgetcsv() method.
Ok, it's badly documented, but this were my first thoughts, the method would never detect the characters and a look into the php source code confirmed this.
Proabably this is a bug?
as you can see here php doc 1st comment 1 year ago - Seems that this function always returns the same delimiter.
UPDATE
this is not a bug look at Pazi ツ answer.

Symfony's sfYaml::load returning a stange value

In a Symfony project, I have the following php code inside a YML file. I was hoping this code would read another yml file and modify the content based upon its value. However, sfYaml::load is returning a string instead of an array. Any ideas why this might be?
In the following code, I expected $s to contain an array, but instead it contains a string with the value "../config/server_settings.yml".
From databases.yml:
dsn: mysql:host=myhost;dbname=mydbname<?php $s = sfYaml::load('../config/server_settings.yml');var_dump($s); ?>
It looks like it's treating your input as a string of yml content, possibly because it can't find the file. Try using the full path or some quick debugging with is_file('../config/server_settings.yml')
It looks like you're trying to define custom settings.
Perhaps this page might help you out:
http://trac.symfony-project.org/wiki/HowToCacheCustomConfiguration

ignore '&' in var contents passed in address bar

i have a download.php file which gets and opens files. i have a problem is that files were named using '&' in the file name so i get file not found when trying to access files with '&' in them.
example: download.phpf=one_&_another.pdf
in the download.php file i use get to the the file name ($_GET['f']) the example above throws the error file not found if i change the file name to one_and_another.pdf it works.
Yes renaming would be nice if there wasnt a whole lot of these files named this way.
I need to know how to ignore the fact that '&' doesnt mean im about to pass another var in php.
If you can control the query strings, you need to URL encode the ampersands so they look like this:
download.php?f=one_%26_another.pdf
Then look for $_GET['f'] as usual. Otherwise a literal ampersand & would break $_GET into
{ 'f' => 'one_', '_another.pdf' => '' }
You will probably just need to urlencode() the & properly in your links:
download.php?f=one_%26_another.pdf
Rule number 1 for accepting user input: do not trust it.
Refer to this StackOverflow answer for your solution.

Categories