Ejemplo n.º 1
0
		private Localize(string moduleName,Collection current,Collection fallback){
			if(current == null && fallback == null){
				throw new System.Exception("Both main and fallback collection is null");
			}
			_main = current;
			_fallback = fallback;
			_moduleName = moduleName;
		}
Ejemplo n.º 2
0
		private Localize(TextAsset current,TextAsset fallback){
			try{
				_current = JsonMapper.ToObject<Collection>(current.text);
				if(fallback != null){
					_fallback = JsonMapper.ToObject<Collection>(fallback.text);
				}
			}catch(System.Exception e){
				Debug.LogException(e);
				Debug.LogError("Json format is wrong!");
				return;
			}
			Localize.active = this;
			_localizeMap.Add(_current.moduelName,this);
		}
Ejemplo n.º 3
0
		public static Collection CSVDecode(string content){
			string[][] cells = new CSVDecoder().Decode(content);
			var collection = new Collection();
			Dictionary<string,string> configMap = new Dictionary<string, string>();
			string[] configs = cells[0];
			for(int i = 0;i<configs.Length/2;i++){
				var key = configs[2*i];
				if(string.IsNullOrEmpty(key.Trim())){
					break;
				}
				var value = configs[2*i+1];
				configMap.Add(key,value);
			}
			collection.language = configMap["language"];
			collection.strings = new Dictionary<string, string>();
			for(int i = 1;i<cells.Length;i++){
				if(string.IsNullOrEmpty(cells[i][0].Trim())){
					break;
				}
				collection.strings.Add(cells[i][0],cells[i][1]);
			}
			return collection;
		}
Ejemplo n.º 4
0
		private Localize(Collection current,Collection fallback){
			_current = current;
			_fallback = fallback;
			Localize.active = this;
			_localizeMap.Add(_current.moduelName,this);
		}