5
// David Makovsk� <yakeen@sannyas-on.net>
5
// David Makovsk� <yakeen@sannyas-on.net>
7
7
// Copyright (C) 1999-2006 Vaclav Slavik (Code and design inspiration - poedit.org)
8
// Copyright (C) 2007 David Makovsk�
8
// Copyright (C) 2007 David Makovsk�
10
10
// Permission is hereby granted, free of charge, to any person obtaining
11
11
// a copy of this software and associated documentation files (the
188
188
public void RemoveReference (string reference)
190
if (references.Contains (reference))
190
if (references.Contains (reference))
191
191
references.Remove (reference);
195
public void SetString (string str)
198
validity = Validity.Unknown;
201
// Sets the plural form (if applicable).
202
public void SetPluralString (string plural)
204
this.plural = plural;
205
this.hasPlural = ! String.IsNullOrEmpty (plural);
208
// Sets the translation. Changes "translated" status to true if \a t is not empty.
209
public void SetTranslation (string translation, int index)
195
public void SetString (string str)
198
validity = Validity.Unknown;
201
// Sets the plural form (if applicable).
202
public void SetPluralString (string plural)
204
this.plural = plural;
205
this.hasPlural = ! String.IsNullOrEmpty (plural);
208
// Sets the translation. Changes "translated" status to true if \a t is not empty.
209
public void SetTranslation (string translation, int index)
211
211
while (index >= translations.Count)
212
212
translations.Add (String.Empty);
214
214
if (translations[index] != translation) {
215
215
translations[index] = translation;
217
217
validity = Validity.Unknown;
218
218
MarkOwnerDirty ();
222
// Sets all translations.
223
public void SetTranslations (string[] translations)
222
// Sets all translations.
223
public void SetTranslations (string[] translations)
225
225
this.translations = new List<string> (translations);
227
227
validity = Validity.Unknown;
228
228
MarkOwnerDirty ();
231
231
// gettext flags directly in string format. It may be
232
232
// either empty string or "#, fuzzy", "#, c-format",
233
233
// #, csharp-format" or others.
234
public string Flags {
238
236
string retStr = String.Empty;
240
238
retStr = ", fuzzy";
245
243
return String.Empty;
250
247
moreFlags = String.Empty;
252
249
if (String.IsNullOrEmpty (value))
255
252
string[] tokens = value.Split (',');
256
foreach (string token in tokens)
253
foreach (string token in tokens) {
258
254
if (token.Trim () == "fuzzy")
263
public bool IsFuzzy {
269
264
get { return isFuzzy; }
273
267
MarkOwnerDirty ();
277
// Translated property
278
public bool IsTranslated
271
// Translated property
272
public bool IsTranslated {
282
274
bool isTranslated = false;
283
275
isTranslated = (translations.Count >= owner.PluralFormsCount) ||
284
276
(! HasPlural && ! String.IsNullOrEmpty (translations[0]));
285
if (isTranslated && HasPlural)
287
for (int i = 0; i <owner.PluralFormsCount; i++)
289
if (String.IsNullOrEmpty (translations[i]))
277
if (isTranslated && HasPlural) {
278
for (int i = 0; i <owner.PluralFormsCount; i++) {
279
if (String.IsNullOrEmpty (translations[i])) {
291
280
isTranslated = false;
300
289
// Modified flag.
301
public bool IsModified
290
public bool IsModified
303
292
get { return isModified; }
304
293
set { isModified = value; }
307
// Automatic translation flag.
308
public bool IsAutomatic
296
// Automatic translation flag.
297
public bool IsAutomatic
310
299
get { return isAutomatic; }
311
300
set { isAutomatic = value; }
314
// Returns true if the gettext flags line contains "foo-format"
315
// flag when called with "foo" as argument.
316
public bool IsInFormat (string format)
303
// Returns true if the gettext flags line contains "foo-format"
304
// flag when called with "foo" as argument.
305
public bool IsInFormat (string format)
318
307
string lookingFor;
319
308
lookingFor = String.Format ("{0}-format", format);
320
309
string[] tokens = moreFlags.Split (',');
321
foreach (string token in tokens)
310
foreach (string token in tokens) {
323
311
if (token.Trim () == lookingFor)
329
// Adds new autocomments (#. )
330
public void AddAutoComment (string comment)
332
autocomments.Add (comment);
335
// Clears autocomments.
336
public void ClearAutoComments ()
338
autocomments.Clear ();
341
// Checks if %i etc. are correct in the translation (true if yes).
342
// Strings that are not c-format are always correct.
343
// TODO: make it checking for c-sharp, .Net string validity
344
public Validity DataValidity
317
// Adds new autocomments (#. )
318
public void AddAutoComment (string comment)
320
autocomments.Add (comment);
323
// Clears autocomments.
324
public void ClearAutoComments ()
326
autocomments.Clear ();
329
// Checks if %i etc. are correct in the translation (true if yes).
330
// Strings that are not c-format are always correct.
331
// TODO: make it checking for c-sharp, .Net string validity
332
public Validity DataValidity
346
334
get { return validity; }
347
335
set { validity = value; }
350
public string ErrorString
338
public string ErrorString
352
340
get { return errorString; }
353
341
set { errorString = value; }
356
344
public string LocaleCode
358
get { return owner.LocaleCode; }
346
get { return owner.LocaleCode; }
361
349
void MarkOwnerDirty ()
363
351
if (owner != null)
364
owner.MarkDirty (this);
352
owner.IsDirty = true;