Wordpress I18n generator: Missing Keys - wordpress

I downloaded the I18n generator package from: http://codex.wordpress.org/I18n_for_WordPress_Developers#Generating_a_POT_file. I want to generate a pot file for my created template now:
php makepot.php /home/mr/workspace/blog/wp-content/themes/myTheme/ de_DE.pot
After executing this command, I get a de_DE.pot with some the WP standard keys in. But my new keys will not be found. But if I add them to the file manually and upload it, they will be translated.
Why doesn't WordPress pick up all my keys?

I have used the poEdit in the following way.
File Menu > New Catalog
Set the language as per your need. Set utf8
Set the paths as . and ..(if you want to place your .mo file at languages folder).
Define the functions from which the strings to take( ie , _, _e, _n, _x, _ex etc).
Now save the file to your template's folder as templateName.po
Now update catalog.
Upon saving the .mo file will be generated in the same folder.
Now rename the .mo file to the specific Locale (for mine bn_BD.mo, for your case de_DE.mo)
I would suggest a few tips from here

Related

Translation files of my plugin are not being loaded or work incorrect

I need to translate some parts of text to French.
Things I've tried so far:
I created fr.po and fr.mo files in my plugin's /languages directory. I used Poedit for this purpose. I've tried different variants like fr_FR - didn't help.
I added the following to my plugin's main file along with its name and other information:
* Text Domain: pluginname
* Domain Path: /languages
Plugin name does not contain any special characters or underscores/dashes - it's a single word.
Also, tried to use load_plugin_textdomain() function instead (or even along with) to make this work.
Also, tried to add this to my wp-config.php file:
define ('WPLANG', 'fr_FR');
Tried to use any combinations of described actions as well.
I have a string to be translated:
__('Recently', 'pluginname')
The word "Recently" is being displayed correctly but it is not being translated if I change site language. I tried both changing in WP admin panel and adding into config file (mentioned above)
I tried to use get_locale() to check if this was actually changed. This returns 'fr_FR' which is exactly the same with my .po/.mo file names.
**P.S.: ** Checked all these questions and tried all suggested solutions - didn't help:
Wordpress - Plugin translation not working
WordPress plugin translation issue
Wordpress plugins translation
Update: load_plugin_textdomain() returns false if I try to var_dump() result right after function execution.
Actually, the problem was in the names of files. Other than locale name it should also consist of the plugin name, e.g. pluginname-fr_FR.po/pluginname-fr_FR.mo for my case. Yes, this is described in the codex, I should read this more attentively :)

How do I load an fixture.yml in silverstripe?

I can't find it in the documentation : Silverstripe-behat-extension
I have a feature file that has some testing scripts. Now I want to fill some test content in a temp database.
So I create a yml file that puts the content in the database.
But how do I load the yml file in my features file?
In your feature use:
Background:
Given a file "/absolute/path/my-data-fixture.yml"

WordPress plugin localization, load_plugin_textdomain doesn't work

Ok i built plugin for contact form, I wanna add translation for it. In my main plugin files i add this code
function ap_action_init() {
// Localization
load_plugin_textdomain('prijava_forma', false, dirname(plugin_basename(__FILE__))."/languages";
}
// Add actions
add_action('init', 'ap_action_init');
in my file where contact form is written i have this
_e( 'Prva','prijava_forma' );
In my language folder I added the .mo and .po files created with Poedit.
Also I defined WPLANG in config.php and changed the language in the dashboard.
But i get no translation. Where could be problem, i am new to this?
There are many possible causes:
.mo file not readable or not found at all (.po file is not used by WordPress by the way)
The string you are expecting is not translated yet
Wrong .mo file name, valid names are ar.mo, fr_FR.mo..., invalid ones are br_BR.mo, arabic.po, AR.mo, ar_AR.mo... So make sure you get this one right.
for plugins the name will be the concatenation for the text domain, a dash and the locale: myplugin-ru_RU.mo
Check what load_plugin_textdomain() returned, if the .mo file was loaded, it should return true, in which case the next step would be to check that you are not missing the textdomain parameter in your __(), _e() and similar functions.
More on WordPress localization
It may be also caused on hook where the functions is attached and where are the po/mo files.
On the Init Hooks, load_plugin_textdomain() returned true but string were not translated.
I changed the action to plugins_loaded as my po/mo were in a folder inside a Custom plugins.
Also make sure that your string stands for itself. Do not append anything to the string, do this after the gettext function instead.
Wrong:
return __('Please translate me'.'(666)','your-textdomain');
Right:
return __('Please translate me','your-textdomain').'(666)';

File renaming functions in wordpress upload process

I have a script that loads posts automatically from a predefined array and uploads images as featured images from a physical path on a local machine.
When I copy the file into upload directory I use path and filename like so:
$upload_dir['path'].'/'.$new_post_id.$filename
This way if I upload apple.jpg several times, the file will be named 1apple.jpg, 2apple.jpg and so on and it will not be overwritten.
I would however like to use Wordpress native functions that check and rename files. In wordpress uploads if you upload apple.jpg several times it will add a new number before the extension like so: apple1.jpg, apple2.jpg and so on, and the number portion is not based on a post.
I was wondering if you could point me to the function in wordpress that does this check and creates new filename so I can use the wordpress native functions for naming my uploaded files.
You need to filter the function wp_unique_post_slug().
As discussed in WPSE.
I found the answer: wp_unique_filename()

Flex : Create new folder in zip file

I am using Flex, Flash Builder 4.5 and Extension Builder 2.0.0 and I use the "nochump ziplib" library to generate a ZIP file. I want to create a new folder in created ZIP file, but I can't find such function function in the "nochump" library.
Can anyone please tell me if there is any function to add new folder in a ZIP file or a library which can help me do this?
The directories are not first-class citizens in the ZIP format.
The archive is built from "entries" - plain files with their relative locations to the "central directory" (the "root" of the archive). This means that the ZIP file is composed from entries like "pictures/1.jpg", "doc/old/1.txt" etc. You don't have separate entries for the "pictures", "doc" or "doc/old" directories.
You can't create a new directory directly. Instead of creating a new directory first (such as "newDir") you may want to create a file (entry) inside instead (such as "newDir/1.txt") and "newDir" will appear as directory when you open the resulting ZIP file.
If you insist on having an empty directory in the archive, you may try the hacky way - adding entries like "newDir/." with zero length. But this may not work with your library.
The Wikipedia article for the ZIP format has all the theory explained pretty well.

Resources