-Fix shortcuts for OSX code completion, fixes #1111
-Fixed how translation fallbacks works, fixes #1011
This commit is contained in:
parent
f39473ae7a
commit
a8bcb96ad4
@ -550,7 +550,7 @@ StringName TranslationServer::translate(const StringName& p_message) const {
|
|||||||
continue; // locale not match
|
continue; // locale not match
|
||||||
|
|
||||||
//near match
|
//near match
|
||||||
bool match = (l!=lptr);
|
bool match = (l!=locale);
|
||||||
|
|
||||||
if (near_match && !match)
|
if (near_match && !match)
|
||||||
continue; //only near-match once
|
continue; //only near-match once
|
||||||
@ -570,6 +570,42 @@ StringName TranslationServer::translate(const StringName& p_message) const {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!res) {
|
||||||
|
//try again with fallback
|
||||||
|
if (fallback.length()>=2) {
|
||||||
|
|
||||||
|
const CharType *fptr=&fallback[0];
|
||||||
|
bool near_match=false;
|
||||||
|
for (const Set< Ref<Translation> >::Element *E=translations.front();E;E=E->next()) {
|
||||||
|
|
||||||
|
const Ref<Translation>& t = E->get();
|
||||||
|
String l = t->get_locale();
|
||||||
|
if (fptr[0]!=l[0] || fptr[1]!=l[1])
|
||||||
|
continue; // locale not match
|
||||||
|
|
||||||
|
//near match
|
||||||
|
bool match = (l!=fallback);
|
||||||
|
|
||||||
|
if (near_match && !match)
|
||||||
|
continue; //only near-match once
|
||||||
|
|
||||||
|
StringName r=t->get_message(p_message);
|
||||||
|
|
||||||
|
if (!r)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
res=r;
|
||||||
|
|
||||||
|
if (match)
|
||||||
|
break;
|
||||||
|
else
|
||||||
|
near_match=true;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!res)
|
if (!res)
|
||||||
return p_message;
|
return p_message;
|
||||||
|
|
||||||
@ -604,9 +640,27 @@ bool TranslationServer::_load_translations(const String& p_from) {
|
|||||||
|
|
||||||
void TranslationServer::setup() {
|
void TranslationServer::setup() {
|
||||||
|
|
||||||
|
String test = GLOBAL_DEF("locale/test","");
|
||||||
|
test=test.strip_edges();
|
||||||
|
if (test!="")
|
||||||
|
set_locale( test );
|
||||||
|
else
|
||||||
|
set_locale( OS::get_singleton()->get_locale() );
|
||||||
|
fallback = GLOBAL_DEF("locale/fallback","en");
|
||||||
|
#ifdef TOOLS_ENABLED
|
||||||
|
|
||||||
set_locale( GLOBAL_DEF("locale/default",OS::get_singleton()->get_locale()) );
|
{
|
||||||
fallback = GLOBAL_DEF("locale/fallback","");
|
String options="";
|
||||||
|
int idx=0;
|
||||||
|
while(locale_list[idx]) {
|
||||||
|
if (idx>0)
|
||||||
|
options+=", ";
|
||||||
|
options+=locale_list[idx];
|
||||||
|
idx++;
|
||||||
|
}
|
||||||
|
Globals::get_singleton()->set_custom_property_info("locale/fallback",PropertyInfo(Variant::STRING,"locale/fallback",PROPERTY_HINT_ENUM,options));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
//load translations
|
//load translations
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -629,6 +683,7 @@ void TranslationServer::load_translations() {
|
|||||||
|
|
||||||
String locale = get_locale();
|
String locale = get_locale();
|
||||||
bool found = _load_translations("locale/translations"); //all
|
bool found = _load_translations("locale/translations"); //all
|
||||||
|
|
||||||
if (_load_translations("locale/translations_"+locale.substr(0,2)))
|
if (_load_translations("locale/translations_"+locale.substr(0,2)))
|
||||||
found=true;
|
found=true;
|
||||||
if ( locale.substr(0,2) != locale ) {
|
if ( locale.substr(0,2) != locale ) {
|
||||||
@ -637,17 +692,6 @@ void TranslationServer::load_translations() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!found && fallback!="") { //none found anywhere, use fallback
|
|
||||||
|
|
||||||
_load_translations("locale/translations_"+fallback.substr(0,2));
|
|
||||||
if ( fallback.substr(0,2) != fallback ) {
|
|
||||||
_load_translations("locale/translations_"+fallback);
|
|
||||||
}
|
|
||||||
|
|
||||||
this->locale=fallback;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TranslationServer::TranslationServer() {
|
TranslationServer::TranslationServer() {
|
||||||
|
@ -1957,7 +1957,11 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
|
|||||||
update();
|
update();
|
||||||
} break;
|
} break;
|
||||||
case KEY_SPACE: {
|
case KEY_SPACE: {
|
||||||
|
#ifdef OSX_ENABLED
|
||||||
|
if (completion_enabled && k.mod.meta) { //cmd-space is spotlight shortcut in OSX
|
||||||
|
#else
|
||||||
if (completion_enabled && k.mod.command) {
|
if (completion_enabled && k.mod.command) {
|
||||||
|
#endif
|
||||||
|
|
||||||
query_code_comple();
|
query_code_comple();
|
||||||
scancode_handled=true;
|
scancode_handled=true;
|
||||||
|
@ -650,8 +650,8 @@ void SurfaceTool::mikktGetTexCoord(const SMikkTSpaceContext * pContext, float fv
|
|||||||
Vector<List<Vertex>::Element*> &varr = *((Vector<List<Vertex>::Element*>*)pContext->m_pUserData);
|
Vector<List<Vertex>::Element*> &varr = *((Vector<List<Vertex>::Element*>*)pContext->m_pUserData);
|
||||||
Vector2 v = varr[iFace*3+iVert]->get().uv;
|
Vector2 v = varr[iFace*3+iVert]->get().uv;
|
||||||
fvTexcOut[0]=v.x;
|
fvTexcOut[0]=v.x;
|
||||||
//fvTexcOut[1]=v.y;
|
fvTexcOut[1]=v.y;
|
||||||
fvTexcOut[1]=1.0-v.y;
|
//fvTexcOut[1]=1.0-v.y;
|
||||||
|
|
||||||
}
|
}
|
||||||
void SurfaceTool::mikktSetTSpaceBasic(const SMikkTSpaceContext * pContext, const float fvTangent[], const float fSign, const int iFace, const int iVert){
|
void SurfaceTool::mikktSetTSpaceBasic(const SMikkTSpaceContext * pContext, const float fvTangent[], const float fSign, const int iFace, const int iVert){
|
||||||
|
@ -1602,7 +1602,11 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
|
|||||||
edit_menu->get_popup()->add_item("Toggle Comment",EDIT_TOGGLE_COMMENT,KEY_MASK_CMD|KEY_K);
|
edit_menu->get_popup()->add_item("Toggle Comment",EDIT_TOGGLE_COMMENT,KEY_MASK_CMD|KEY_K);
|
||||||
edit_menu->get_popup()->add_item("Clone Down",EDIT_CLONE_DOWN,KEY_MASK_CMD|KEY_B);
|
edit_menu->get_popup()->add_item("Clone Down",EDIT_CLONE_DOWN,KEY_MASK_CMD|KEY_B);
|
||||||
edit_menu->get_popup()->add_separator();
|
edit_menu->get_popup()->add_separator();
|
||||||
|
#ifdef OSX_ENABLED
|
||||||
|
edit_menu->get_popup()->add_item("Complete Symbol",EDIT_COMPLETE,KEY_MASK_META|KEY_SPACE);
|
||||||
|
#else
|
||||||
edit_menu->get_popup()->add_item("Complete Symbol",EDIT_COMPLETE,KEY_MASK_CMD|KEY_SPACE);
|
edit_menu->get_popup()->add_item("Complete Symbol",EDIT_COMPLETE,KEY_MASK_CMD|KEY_SPACE);
|
||||||
|
#endif
|
||||||
edit_menu->get_popup()->add_item("Auto Indent",EDIT_AUTO_INDENT,KEY_MASK_CMD|KEY_I);
|
edit_menu->get_popup()->add_item("Auto Indent",EDIT_AUTO_INDENT,KEY_MASK_CMD|KEY_I);
|
||||||
edit_menu->get_popup()->connect("item_pressed", this,"_menu_option");
|
edit_menu->get_popup()->connect("item_pressed", this,"_menu_option");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user