forked from bartvdbraak/blender
store locales, .Blanguage, and .bfont.ttf inside of Resources folder of
application bundle on OS X
This commit is contained in:
parent
936f7541c4
commit
eca049b177
@ -41,14 +41,13 @@
|
|||||||
#include "libintl.h"
|
#include "libintl.h"
|
||||||
#include "BLI_blenlib.h"
|
#include "BLI_blenlib.h"
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
#include <libgen.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "../FTF_Settings.h"
|
#include "../FTF_Settings.h"
|
||||||
|
|
||||||
#include "FTF_TTFont.h"
|
#include "FTF_TTFont.h"
|
||||||
|
|
||||||
|
#include "BKE_utildefines.h"
|
||||||
|
#include "BLI_blenlib.h"
|
||||||
|
|
||||||
#define DOMAIN_NAME "blender"
|
#define DOMAIN_NAME "blender"
|
||||||
|
|
||||||
#define SYSTEM_ENCODING_DEFAULT "UTF-8"
|
#define SYSTEM_ENCODING_DEFAULT "UTF-8"
|
||||||
@ -57,8 +56,6 @@
|
|||||||
|
|
||||||
#define FTF_MAX_STR_SIZE 256
|
#define FTF_MAX_STR_SIZE 256
|
||||||
|
|
||||||
extern char bprogname[];
|
|
||||||
|
|
||||||
int utf8towchar(wchar_t *w, char *c)
|
int utf8towchar(wchar_t *w, char *c)
|
||||||
{
|
{
|
||||||
int len=0;
|
int len=0;
|
||||||
@ -104,7 +101,7 @@ int utf8towchar(wchar_t *w, char *c)
|
|||||||
FTF_TTFont::FTF_TTFont(void)
|
FTF_TTFont::FTF_TTFont(void)
|
||||||
{
|
{
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
char tmp[1024];
|
char *bundlepath;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
font=NULL;
|
font=NULL;
|
||||||
@ -117,33 +114,26 @@ FTF_TTFont::FTF_TTFont(void)
|
|||||||
#define LOCALEDIR "/usr/share/locale"
|
#define LOCALEDIR "/usr/share/locale"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
BLI_make_file_string("/", messagepath, BLI_gethome(), ".blender/locale");
|
strcpy(messagepath, ".blender/locale");
|
||||||
printf("1. %s\n", messagepath);
|
|
||||||
if (BLI_exist(messagepath) == NULL) { // locale not in home dir
|
|
||||||
|
|
||||||
strcpy(messagepath, ".blender/locale");
|
|
||||||
printf("2. %s\n", messagepath);
|
|
||||||
if(BLI_exist(messagepath) == NULL) { // locale not in current dir
|
|
||||||
|
|
||||||
strcpy(messagepath, LOCALEDIR);
|
|
||||||
printf("3. %s\n", messagepath);
|
|
||||||
if(BLI_exist(messagepath) == NULL) { // locale not in LOCALEDIR
|
|
||||||
|
|
||||||
|
|
||||||
|
if (BLI_exist(messagepath) == NULL) { // locale not in current dir
|
||||||
|
BLI_make_file_string("/", messagepath, BLI_gethome(), ".blender/locale");
|
||||||
|
|
||||||
|
if(BLI_exist(messagepath) == NULL) { // locale not in home dir
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
/* message catalogs are stored inside the application bundle */
|
/* message catalogs are stored inside the application bundle */
|
||||||
strcpy(tmp, dirname(bprogname));
|
bundlepath = BLI_getbundle();
|
||||||
strcat(tmp, "/../Resources/message");
|
strcpy(messagepath, bundlepath);
|
||||||
realpath(tmp, messagepath);
|
strcat(messagepath, "/Contents/Resources/locale");
|
||||||
printf("4. %s\n", messagepath);
|
if(BLI_exist(messagepath) == NULL) { // locale not in bundle (now that's odd..)
|
||||||
if(BLI_exist(messagepath) == NULL) { // locale not in bundle dir
|
|
||||||
#endif
|
#endif
|
||||||
|
strcpy(messagepath, LOCALEDIR);
|
||||||
|
|
||||||
|
if(BLI_exist(messagepath) == NULL) { // locale not in LOCALEDIR
|
||||||
strcpy(messagepath, "message"); // old compatibility as last
|
strcpy(messagepath, "message"); // old compatibility as last
|
||||||
printf("5. %s\n", messagepath);
|
|
||||||
}
|
}
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
} // heh
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -193,12 +183,9 @@ void FTF_TTFont::SetLanguage(char* str)
|
|||||||
gettext_putenv(envstr);
|
gettext_putenv(envstr);
|
||||||
#else
|
#else
|
||||||
putenv(envstr);
|
putenv(envstr);
|
||||||
setlocale(LC_ALL, str);
|
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
char *locreturn;
|
char *locreturn = setlocale(LC_ALL, str);
|
||||||
|
|
||||||
locreturn = setlocale(LC_ALL, str);
|
|
||||||
if (locreturn == NULL) {
|
if (locreturn == NULL) {
|
||||||
printf("could not change language to %s\n", str);
|
printf("could not change language to %s\n", str);
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ void lang_setlanguage(void) {
|
|||||||
LANGMenuEntry *lme;
|
LANGMenuEntry *lme;
|
||||||
|
|
||||||
lme = find_language(U.language);
|
lme = find_language(U.language);
|
||||||
if(lme) FTF_SetLanguage(lme->code);
|
if(lme) FTF_SetLanguage(lme->code);
|
||||||
else FTF_SetLanguage("en_US");
|
else FTF_SetLanguage("en_US");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,11 +154,14 @@ void set_interface_font(char *str) {
|
|||||||
void start_interface_font(void) {
|
void start_interface_font(void) {
|
||||||
char tstr[FILE_MAXDIR+FILE_MAXFILE];
|
char tstr[FILE_MAXDIR+FILE_MAXFILE];
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
#ifdef __APPLE__
|
||||||
|
char *bundlepath;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* hack to find out if we have saved language/font settings.
|
/* hack to find out if we have saved language/font settings.
|
||||||
if not, set defaults and try .bfont.tff --phase */
|
if not, set defaults and try .bfont.tff --phase */
|
||||||
|
|
||||||
if(U.fontsize != 0) { // we have saved user settings
|
if(U.fontsize != 0) { // we have saved user settings
|
||||||
// try load the font from the font dir
|
// try load the font from the font dir
|
||||||
BLI_make_file_string("/", tstr, U.fontdir, U.fontname);
|
BLI_make_file_string("/", tstr, U.fontdir, U.fontname);
|
||||||
result = FTF_SetFont(tstr, U.fontsize);
|
result = FTF_SetFont(tstr, U.fontsize);
|
||||||
@ -170,9 +173,20 @@ void start_interface_font(void) {
|
|||||||
U.language= 0;
|
U.language= 0;
|
||||||
U.fontsize= 11;
|
U.fontsize= 11;
|
||||||
U.encoding= 0;
|
U.encoding= 0;
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
bundlepath = BLI_getbundle();
|
||||||
|
strcpy(tstr, bundlepath);
|
||||||
|
strcat(tstr, "/Contents/Resources/");
|
||||||
|
strcat(tstr, ".bfont.ttf");
|
||||||
|
result = FTF_SetFont(tstr, U.fontsize);
|
||||||
|
|
||||||
|
sprintf(U.fontname, ".blender/.bfont.ttf\0");
|
||||||
|
#else
|
||||||
sprintf(U.fontname, ".blender/.bfont.ttf\0");
|
sprintf(U.fontname, ".blender/.bfont.ttf\0");
|
||||||
|
|
||||||
result = FTF_SetFont(U.fontname, U.fontsize);
|
result = FTF_SetFont(U.fontname, U.fontsize);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if(result) {
|
if(result) {
|
||||||
@ -250,15 +264,22 @@ void puplang_insert_entry(char *line)
|
|||||||
int read_languagefile(void) {
|
int read_languagefile(void) {
|
||||||
char name[FILE_MAXDIR+FILE_MAXFILE];
|
char name[FILE_MAXDIR+FILE_MAXFILE];
|
||||||
LinkNode *l, *lines;
|
LinkNode *l, *lines;
|
||||||
|
|
||||||
/* .Blanguages */
|
/* .Blanguages */
|
||||||
|
|
||||||
BLI_make_file_string("/", name, BLI_gethome(), ".Blanguages");
|
BLI_make_file_string("/", name, BLI_gethome(), ".Blanguages");
|
||||||
|
|
||||||
lines= BLI_read_file_as_lines(name);
|
lines= BLI_read_file_as_lines(name);
|
||||||
|
|
||||||
if(lines == NULL) {
|
if(lines == NULL) {
|
||||||
/* If not found in home, try .blender dir */
|
/* If not found in home, try current dir
|
||||||
strcpy(name, ".blender\\.Blanguages");
|
* (Resources folder of app bundle on OS X) */
|
||||||
|
#ifdef __APPLE__
|
||||||
|
char *bundlePath = BLI_getbundle();
|
||||||
|
strcpy(name, bundlePath);
|
||||||
|
strcat(name, "/Contents/Resources/.Blanguages");
|
||||||
|
#else
|
||||||
|
strcpy(name, ".blender/.Blanguages");
|
||||||
|
#endif
|
||||||
lines= BLI_read_file_as_lines(name);
|
lines= BLI_read_file_as_lines(name);
|
||||||
|
|
||||||
if(lines == NULL) {
|
if(lines == NULL) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# $Id: Makefile,v 1.5 2003/02/09 18:32:55 sgefant Exp $
|
# $Id: Makefile,v 1.6 2003/05/09 20:20:40 sgefant Exp $
|
||||||
#
|
#
|
||||||
# ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
|
# ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
|
||||||
#
|
#
|
||||||
@ -46,7 +46,10 @@ all::
|
|||||||
@chmod +x $(DIR)/bin/$(APPLICATION).app/Contents/MacOS/$(APPLICATION)
|
@chmod +x $(DIR)/bin/$(APPLICATION).app/Contents/MacOS/$(APPLICATION)
|
||||||
ifeq ($(APPLICATION), blender)
|
ifeq ($(APPLICATION), blender)
|
||||||
@echo "---> copying message files"
|
@echo "---> copying message files"
|
||||||
@cp -R ../../bin/message $(DIR)/bin/$(APPLICATION).app/Contents/Resources
|
@cp -R ../../bin/.blender/locale $(DIR)/bin/$(APPLICATION).app/Contents/Resources
|
||||||
|
@echo "---> copying .Blanguages and .bfont.ttf"
|
||||||
|
@cp ../../bin/.blender/.Blanguages $(DIR)/bin/$(APPLICATION).app/Contents/Resources
|
||||||
|
@cp ../../bin/.blender/.bfont.ttf $(DIR)/bin/$(APPLICATION).app/Contents/Resources
|
||||||
endif
|
endif
|
||||||
@echo "---> removing CVS directories and Mac hidden files from distribution"
|
@echo "---> removing CVS directories and Mac hidden files from distribution"
|
||||||
@find $(DIR)/bin/$(APPLICATION).app -name CVS -prune -exec rm -rf {} \;
|
@find $(DIR)/bin/$(APPLICATION).app -name CVS -prune -exec rm -rf {} \;
|
||||||
|
Loading…
Reference in New Issue
Block a user