ObjFW  Diff

Differences From Artifact [0a1b003490]:

To Artifact [b0fb42c722]:


79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
		return self;
	}

	locale = of_strdup(locale);

	@try {
		char *tmp;
		size_t tmpLen;

		/* We don't care for extras behind the @ */
		if ((tmp = strrchr(locale, '@')) != NULL)
			*tmp = '\0';

		/* Encoding */
		if ((tmp = strrchr(locale, '.')) != NULL) {







<







79
80
81
82
83
84
85

86
87
88
89
90
91
92
		return self;
	}

	locale = of_strdup(locale);

	@try {
		char *tmp;


		/* We don't care for extras behind the @ */
		if ((tmp = strrchr(locale, '@')) != NULL)
			*tmp = '\0';

		/* Encoding */
		if ((tmp = strrchr(locale, '.')) != NULL) {
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
			}
		}

		/* Territory */
		if ((tmp = strrchr(locale, '_')) != NULL) {
			*tmp++ = '\0';

			tmpLen = strlen(tmp);
			for (size_t i = 0; i < tmpLen; i++)
				tmp[i] = of_ascii_tolower(tmp[i]);

			_territory = [[OFString alloc]
			    initWithCString: tmp
				   encoding: OF_STRING_ENCODING_ASCII
				     length: tmpLen];
		}

		tmpLen = strlen(locale);
		for (size_t i = 0; i < tmpLen; i++)
			locale[i] = of_ascii_tolower(locale[i]);

		_language = [[OFString alloc]
		    initWithCString: locale
			   encoding: OF_STRING_ENCODING_ASCII
			     length: tmpLen];

		_decimalPoint = [[OFString alloc]
		    initWithCString: localeconv()->decimal_point
			   encoding: _encoding];
	} @catch (id e) {
		[self release];
		@throw e;







<
<
<
<


|
<


<
<
<
<


|
<







103
104
105
106
107
108
109




110
111
112

113
114




115
116
117

118
119
120
121
122
123
124
			}
		}

		/* Territory */
		if ((tmp = strrchr(locale, '_')) != NULL) {
			*tmp++ = '\0';





			_territory = [[OFString alloc]
			    initWithCString: tmp
				   encoding: OF_STRING_ENCODING_ASCII];

		}





		_language = [[OFString alloc]
		    initWithCString: locale
			   encoding: OF_STRING_ENCODING_ASCII];


		_decimalPoint = [[OFString alloc]
		    initWithCString: localeconv()->decimal_point
			   encoding: _encoding];
	} @catch (id e) {
		[self release];
		@throw e;
155
156
157
158
159
160
161
162
163



164
165
166
167
168
169
170
171
172
173
- (void)addLanguageDirectory: (OFString*)path
{
	void *pool = objc_autoreleasePoolPush();
	OFString *mapPath =
	    [path stringByAppendingPathComponent: @"languages.json"];
	OFDictionary *map =
	    [[OFString stringWithContentsOfFile: mapPath] JSONValue];
	OFString *languageFile;




	languageFile = [[map objectForKey: _language] objectForKey: _territory];
	if (languageFile == nil)
		languageFile = [[map objectForKey: _language]
		    objectForKey: @""];

	if (languageFile == nil) {
		objc_autoreleasePoolPop(pool);
		return;
	}








|

>
>
>
|

|







144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
- (void)addLanguageDirectory: (OFString*)path
{
	void *pool = objc_autoreleasePoolPush();
	OFString *mapPath =
	    [path stringByAppendingPathComponent: @"languages.json"];
	OFDictionary *map =
	    [[OFString stringWithContentsOfFile: mapPath] JSONValue];
	OFString *language, *territory, *languageFile;

	language = [_language lowercaseString];
	territory = [_territory lowercaseString];

	languageFile = [[map objectForKey: language] objectForKey: territory];
	if (languageFile == nil)
		languageFile = [[map objectForKey: language]
		    objectForKey: @""];

	if (languageFile == nil) {
		objc_autoreleasePoolPop(pool);
		return;
	}