1 /** 2 Language Translation. 3 4 Copyright: 5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. 6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) 7 Copyright (c) 2017-2018 Godot-D contributors 8 9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License) 10 11 12 */ 13 module godot.translation; 14 import std.meta : AliasSeq, staticIndexOf; 15 import std.traits : Unqual; 16 import godot.d.traits; 17 import godot.core; 18 import godot.c; 19 import godot.d.bind; 20 import godot.d.reference; 21 import godot.globalenums; 22 import godot.object; 23 import godot.classdb; 24 import godot.resource; 25 import godot.reference; 26 /** 27 Language Translation. 28 29 Translations are resources that can be loaded and unloaded on demand. They map a string to another string. 30 */ 31 @GodotBaseClass struct Translation 32 { 33 package(godot) enum string _GODOT_internal_name = "Translation"; 34 public: 35 @nogc nothrow: 36 union { /** */ godot_object _godot_object; /** */ Resource _GODOT_base; } 37 alias _GODOT_base this; 38 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 39 package(godot) __gshared bool _classBindingInitialized = false; 40 package(godot) static struct GDNativeClassBinding 41 { 42 __gshared: 43 @GodotName("_get_messages") GodotMethod!(PoolStringArray) _getMessages; 44 @GodotName("_set_messages") GodotMethod!(void, PoolStringArray) _setMessages; 45 @GodotName("add_message") GodotMethod!(void, String, String) addMessage; 46 @GodotName("erase_message") GodotMethod!(void, String) eraseMessage; 47 @GodotName("get_locale") GodotMethod!(String) getLocale; 48 @GodotName("get_message") GodotMethod!(String, String) getMessage; 49 @GodotName("get_message_count") GodotMethod!(long) getMessageCount; 50 @GodotName("get_message_list") GodotMethod!(PoolStringArray) getMessageList; 51 @GodotName("set_locale") GodotMethod!(void, String) setLocale; 52 } 53 /// 54 pragma(inline, true) bool opEquals(in Translation other) const 55 { return _godot_object.ptr is other._godot_object.ptr; } 56 /// 57 pragma(inline, true) typeof(null) opAssign(typeof(null) n) 58 { _godot_object.ptr = n; return null; } 59 /// 60 pragma(inline, true) bool opEquals(typeof(null) n) const 61 { return _godot_object.ptr is n; } 62 /// 63 size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; } 64 mixin baseCasts; 65 /// Construct a new instance of Translation. 66 /// Note: use `memnew!Translation` instead. 67 static Translation _new() 68 { 69 static godot_class_constructor constructor; 70 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("Translation"); 71 if(constructor is null) return typeof(this).init; 72 return cast(Translation)(constructor()); 73 } 74 @disable new(size_t s); 75 /** 76 77 */ 78 PoolStringArray _getMessages() const 79 { 80 Array _GODOT_args = Array.make(); 81 String _GODOT_method_name = String("_get_messages"); 82 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!PoolStringArray); 83 } 84 /** 85 86 */ 87 void _setMessages(in PoolStringArray arg0) 88 { 89 Array _GODOT_args = Array.make(); 90 _GODOT_args.append(arg0); 91 String _GODOT_method_name = String("_set_messages"); 92 this.callv(_GODOT_method_name, _GODOT_args); 93 } 94 /** 95 Adds a message if nonexistent, followed by its translation. 96 */ 97 void addMessage(in String src_message, in String xlated_message) 98 { 99 checkClassBinding!(typeof(this))(); 100 ptrcall!(void)(GDNativeClassBinding.addMessage, _godot_object, src_message, xlated_message); 101 } 102 /** 103 Erases a message. 104 */ 105 void eraseMessage(in String src_message) 106 { 107 checkClassBinding!(typeof(this))(); 108 ptrcall!(void)(GDNativeClassBinding.eraseMessage, _godot_object, src_message); 109 } 110 /** 111 112 */ 113 String getLocale() const 114 { 115 checkClassBinding!(typeof(this))(); 116 return ptrcall!(String)(GDNativeClassBinding.getLocale, _godot_object); 117 } 118 /** 119 Returns a message's translation. 120 */ 121 String getMessage(in String src_message) const 122 { 123 checkClassBinding!(typeof(this))(); 124 return ptrcall!(String)(GDNativeClassBinding.getMessage, _godot_object, src_message); 125 } 126 /** 127 Returns the number of existing messages. 128 */ 129 long getMessageCount() const 130 { 131 checkClassBinding!(typeof(this))(); 132 return ptrcall!(long)(GDNativeClassBinding.getMessageCount, _godot_object); 133 } 134 /** 135 Returns all the messages (keys). 136 */ 137 PoolStringArray getMessageList() const 138 { 139 checkClassBinding!(typeof(this))(); 140 return ptrcall!(PoolStringArray)(GDNativeClassBinding.getMessageList, _godot_object); 141 } 142 /** 143 144 */ 145 void setLocale(in String locale) 146 { 147 checkClassBinding!(typeof(this))(); 148 ptrcall!(void)(GDNativeClassBinding.setLocale, _godot_object, locale); 149 } 150 /** 151 The locale of the translation. 152 */ 153 @property String locale() 154 { 155 return getLocale(); 156 } 157 /// ditto 158 @property void locale(String v) 159 { 160 setLocale(v); 161 } 162 /** 163 164 */ 165 @property PoolStringArray messages() 166 { 167 return _getMessages(); 168 } 169 /// ditto 170 @property void messages(PoolStringArray v) 171 { 172 _setMessages(v); 173 } 174 }