This commit adds:
* A new bpy.app.translations module giving some info about locales/translation stuff (current active locale, all locales currently known by blender, all translation contexts currently defined, etc.).
* The ability for addons to feature translations, using the (un)register functions of above module.
* Also cleans up "translate py string when storing into RNA prop" by removing "PROP_TRANSLATE" string's subtype, and adding a PROP_STRING_PY_TRANSLATE flag instead (this way it is no more exposed to python...).
Addon translations work with py dictionaries: each addon features a dict {lang: {(context, message): translation, ...}, ...}, which is registered when the addon is enabled (and unregistered when disabled). 
Then, when a key (context, message) is not found in regular mo catalog, a cache dict for current locale is built from all registered addon translations, and key is searched in it.
Note: currently addons writers have to do all the work by hand, will add something (probably extend "edit translation" addon) to automate messages extraction from addons soon(ish)! To get a look to expected behavior from addons, have a look at render_copy_settings/__init__.py and render_copy_settings/translations.py (rather stupid example currently, but...). Once we have a complete process, I'll also update relevant wiki pages.
		
	
		
			
				
	
	
		
			100 lines
		
	
	
		
			3.5 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			100 lines
		
	
	
		
			3.5 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
/*
 | 
						|
 * ***** BEGIN GPL LICENSE BLOCK *****
 | 
						|
 *
 | 
						|
 * This program is free software; you can redistribute it and/or
 | 
						|
 * modify it under the terms of the GNU General Public License
 | 
						|
 * as published by the Free Software Foundation; either version 2
 | 
						|
 * of the License, or (at your option) any later version.
 | 
						|
 *
 | 
						|
 * This program is distributed in the hope that it will be useful,
 | 
						|
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
						|
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
						|
 * GNU General Public License for more details.
 | 
						|
 *
 | 
						|
 * You should have received a copy of the GNU General Public License
 | 
						|
 * along with this program; if not, write to the Free Software Foundation,
 | 
						|
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 | 
						|
 *
 | 
						|
 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
 | 
						|
 * All rights reserved.
 | 
						|
 *
 | 
						|
 * The Original Code was in: source/blender/bpython/include/BPY_extern.h
 | 
						|
 *
 | 
						|
 * Contributor(s): Michel Selten,
 | 
						|
 *                 Willian P. Germano,
 | 
						|
 *                 Chris Keith,
 | 
						|
 *                 Campbell Barton
 | 
						|
 *
 | 
						|
 * ***** END GPL LICENSE BLOCK *****
 | 
						|
 */
 | 
						|
 | 
						|
/** \file BPY_extern.h
 | 
						|
 *  \ingroup python
 | 
						|
 */
 | 
						|
 | 
						|
 | 
						|
 | 
						|
#ifndef __BPY_EXTERN_H__
 | 
						|
#define __BPY_EXTERN_H__
 | 
						|
 | 
						|
struct Text; /* defined in DNA_text_types.h */
 | 
						|
struct ID; /* DNA_ID.h */
 | 
						|
struct Object; /* DNA_object_types.h */
 | 
						|
struct ChannelDriver; /* DNA_anim_types.h */
 | 
						|
struct ListBase; /* DNA_listBase.h */
 | 
						|
struct bConstraint; /* DNA_constraint_types.h */
 | 
						|
struct bPythonConstraint; /* DNA_constraint_types.h */
 | 
						|
struct bConstraintOb; /* DNA_constraint_types.h */
 | 
						|
struct bConstraintTarget; /* DNA_constraint_types.h*/
 | 
						|
struct bContext;
 | 
						|
struct bContextDataResult;
 | 
						|
struct ReportList;
 | 
						|
 | 
						|
#ifdef __cplusplus
 | 
						|
extern "C" {
 | 
						|
#endif
 | 
						|
 | 
						|
void BPY_pyconstraint_exec(struct bPythonConstraint *con, struct bConstraintOb *cob, struct ListBase *targets);
 | 
						|
//	void BPY_pyconstraint_settings(void *arg1, void *arg2);
 | 
						|
void BPY_pyconstraint_target(struct bPythonConstraint *con, struct bConstraintTarget *ct);
 | 
						|
void BPY_pyconstraint_update(struct Object *owner, struct bConstraint *con);
 | 
						|
int BPY_is_pyconstraint(struct Text *text);
 | 
						|
//	void BPY_free_pyconstraint_links(struct Text *text);
 | 
						|
 | 
						|
void BPY_python_start(int argc, const char **argv);
 | 
						|
void BPY_python_end(void);
 | 
						|
 | 
						|
/* 2.5 UI Scripts */
 | 
						|
int		BPY_filepath_exec(struct bContext *C, const char *filepath, struct ReportList *reports);
 | 
						|
int		BPY_text_exec(struct bContext *C, struct Text *text, struct ReportList *reports, const bool do_jump);
 | 
						|
void	BPY_text_free_code(struct Text *text);
 | 
						|
void	BPY_modules_update(struct bContext *C); // XXX - annoying, need this for pointers that get out of date
 | 
						|
void	BPY_modules_load_user(struct bContext *C);
 | 
						|
 | 
						|
void	BPY_app_handlers_reset(const short do_all);
 | 
						|
 | 
						|
void	BPY_driver_reset(void);
 | 
						|
float	BPY_driver_exec(struct ChannelDriver *driver, const float evaltime);
 | 
						|
 | 
						|
int		BPY_button_exec(struct bContext *C, const char *expr, double *value, const short verbose);
 | 
						|
int		BPY_string_exec(struct bContext *C, const char *expr);
 | 
						|
 | 
						|
void	BPY_DECREF(void *pyob_ptr);	/* Py_DECREF() */
 | 
						|
void	BPY_DECREF_RNA_INVALIDATE(void *pyob_ptr);
 | 
						|
int		BPY_context_member_get(struct bContext *C, const char *member, struct bContextDataResult *result);
 | 
						|
void	BPY_context_set(struct bContext *C);
 | 
						|
void	BPY_context_update(struct bContext *C);
 | 
						|
 | 
						|
void	BPY_id_release(struct ID *id);
 | 
						|
 | 
						|
/* I18n for addons */
 | 
						|
#ifdef WITH_INTERNATIONAL
 | 
						|
const char *BPY_app_translations_py_pgettext(const char *msgctxt, const char *msgid);
 | 
						|
#endif
 | 
						|
 | 
						|
#ifdef __cplusplus
 | 
						|
}				/* extern "C" */
 | 
						|
#endif
 | 
						|
 | 
						|
#endif  /* __BPY_EXTERN_H__ */
 |