~ubuntu-branches/ubuntu/oneiric/monodevelop/oneiric-updates

« back to all changes in this revision

Viewing changes to src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext/CatalogEntry.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2009-02-18 08:40:51 UTC
  • mfrom: (1.2.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090218084051-gh8m6ukvokbwj7cf
Tags: 1.9.2+dfsg-1ubuntu1
* Merge from Debian Experimental (LP: #330519), remaining Ubuntu changes:
  + debian/control:
    - Update for Gnome# 2.24
    - Add libmono-cairo1.0-cil to build-deps to fool pkg-config check

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
// CatalogEntry.cs
3
3
//
4
4
// Author:
5
 
//   David Makovsk� <yakeen@sannyas-on.net>
 
5
//   David Makovsk� <yakeen@sannyas-on.net>
6
6
//
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�
9
9
//
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
187
187
                
188
188
                public void RemoveReference (string reference)
189
189
                {
190
 
            if (references.Contains (reference))
 
190
                        if (references.Contains (reference))
191
191
                                references.Remove (reference);
192
192
                }
193
 
 
194
 
        // Sets the string.
195
 
        public void SetString (string str)
196
 
        {
197
 
            this.str = str;
198
 
            validity = Validity.Unknown;
199
 
        }
200
 
 
201
 
        // Sets the plural form (if applicable).
202
 
        public void SetPluralString (string plural)
203
 
        {
204
 
            this.plural = plural;
205
 
            this.hasPlural = ! String.IsNullOrEmpty (plural);
206
 
        }
207
 
 
208
 
        // Sets the translation. Changes "translated" status to true if \a t is not empty.
209
 
        public void SetTranslation (string translation, int index)
210
 
        {
 
193
                
 
194
                // Sets the string.
 
195
                public void SetString (string str)
 
196
                {
 
197
                        this.str = str;
 
198
                        validity = Validity.Unknown;
 
199
                }
 
200
                
 
201
                // Sets the plural form (if applicable).
 
202
                public void SetPluralString (string plural)
 
203
                {
 
204
                        this.plural = plural;
 
205
                        this.hasPlural = ! String.IsNullOrEmpty (plural);
 
206
                }
 
207
                
 
208
                // Sets the translation. Changes "translated" status to true if \a t is not empty.
 
209
                public void SetTranslation (string translation, int index)
 
210
                {
211
211
                        while (index >= translations.Count)
212
212
                                translations.Add (String.Empty);
213
213
                        
214
214
                        if (translations[index] != translation) {
215
215
                                translations[index] = translation;
216
 
 
 
216
                                
217
217
                                validity = Validity.Unknown;
218
218
                                MarkOwnerDirty ();
219
219
                        }
220
 
        }
221
 
 
222
 
        // Sets all translations.
223
 
        public void SetTranslations (string[] translations)
224
 
        {
 
220
                }
 
221
                
 
222
                // Sets all translations.
 
223
                public void SetTranslations (string[] translations)
 
224
                {
225
225
                        this.translations = new List<string> (translations);
226
 
 
 
226
                        
227
227
                        validity = Validity.Unknown;
228
228
                        MarkOwnerDirty ();
229
 
        }
 
229
                }
230
230
                
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
235
 
                {
236
 
                        get
237
 
                        {
 
234
                public string Flags {
 
235
                        get {
238
236
                                string retStr = String.Empty;
239
237
                                if (isFuzzy)
240
238
                                        retStr = ", fuzzy";
244
242
                                else
245
243
                                        return String.Empty;
246
244
                        }
247
 
                        set
248
 
                        {
 
245
                        set {
249
246
                                isFuzzy = false;
250
247
                                moreFlags = String.Empty;
251
 
 
 
248
                                
252
249
                                if (String.IsNullOrEmpty (value))
253
250
                                        return;
254
251
                                
255
252
                                string[] tokens = value.Split (',');
256
 
                                foreach (string token in tokens)
257
 
                                {
 
253
                                foreach (string token in tokens) {
258
254
                                        if (token.Trim () == "fuzzy")
259
255
                                                isFuzzy = true;
260
256
                                        else
262
258
                                }
263
259
                        }
264
260
                }
265
 
        
 
261
                
266
262
                // Fuzzy flag
267
 
                public bool IsFuzzy
268
 
                {
 
263
                public bool IsFuzzy {
269
264
                        get { return isFuzzy; }
270
 
                        set
271
 
                        {
 
265
                        set {
272
266
                                isFuzzy = value;
273
267
                                MarkOwnerDirty ();
274
268
                        }
275
269
                }
276
 
        
277
 
        // Translated property
278
 
        public bool IsTranslated 
279
 
        {
280
 
                        get
281
 
                        {
 
270
                
 
271
                // Translated property
 
272
                public bool IsTranslated  {
 
273
                        get {
282
274
                                bool isTranslated = false;    
283
275
                                isTranslated = (translations.Count >= owner.PluralFormsCount) ||
284
276
                                        (! HasPlural && ! String.IsNullOrEmpty (translations[0]));
285
 
                                if (isTranslated && HasPlural)
286
 
                                {
287
 
                                        for (int i = 0; i <owner.PluralFormsCount; i++)
288
 
                                        {
289
 
                                                if (String.IsNullOrEmpty (translations[i]))
290
 
                                                {
 
277
                                if (isTranslated && HasPlural) {
 
278
                                        for (int i = 0; i <owner.PluralFormsCount; i++) {
 
279
                                                if (String.IsNullOrEmpty (translations[i])) {
291
280
                                                        isTranslated = false;
292
281
                                                        break;
293
282
                                                }
298
287
                }
299
288
                
300
289
                // Modified flag.
301
 
        public bool IsModified
302
 
        {
 
290
                public bool IsModified
 
291
                {
303
292
                        get { return isModified; }
304
293
                        set { isModified = value; }
305
294
                }
306
295
                
307
 
        // Automatic translation flag.
308
 
        public bool IsAutomatic
309
 
        {
 
296
                // Automatic translation flag.
 
297
                public bool IsAutomatic
 
298
                {
310
299
                        get { return isAutomatic; }
311
300
                        set { isAutomatic = value; }
312
301
                }
313
302
                
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)
317
 
        {
 
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)
 
306
                {
318
307
                        string lookingFor;
319
308
                        lookingFor = String.Format ("{0}-format", format);
320
309
                        string[] tokens = moreFlags.Split (',');
321
 
                        foreach (string token in tokens)
322
 
                        {
 
310
                        foreach (string token in tokens) {
323
311
                                if (token.Trim () == lookingFor)
324
312
                                        return true;
325
313
                        }
326
314
                        return false;
327
 
        }
328
 
 
329
 
        // Adds new autocomments (#. )
330
 
        public void AddAutoComment (string comment)
331
 
        {
332
 
            autocomments.Add (comment);
333
 
        }
334
 
 
335
 
        // Clears autocomments.
336
 
        public void ClearAutoComments ()
337
 
        {
338
 
            autocomments.Clear ();
339
 
        }
340
 
 
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
345
 
        {
 
315
                }
 
316
                
 
317
                // Adds new autocomments (#. )
 
318
                public void AddAutoComment (string comment)
 
319
                {
 
320
                        autocomments.Add (comment);
 
321
                }
 
322
                
 
323
                // Clears autocomments.
 
324
                public void ClearAutoComments ()
 
325
                {
 
326
                        autocomments.Clear ();
 
327
                }
 
328
                
 
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
 
333
                {
346
334
                        get { return validity; }
347
335
                        set { validity = value; }
348
336
                }
349
 
 
350
 
        public string ErrorString
351
 
        {
 
337
                
 
338
                public string ErrorString
 
339
                {
352
340
                        get { return errorString; }
353
341
                        set { errorString = value; }
354
342
                }
355
343
                
356
344
                public string LocaleCode
357
 
        {
358
 
                get { return owner.LocaleCode; }
359
 
        }
 
345
                {
 
346
                        get { return owner.LocaleCode; }
 
347
                }
360
348
                
361
349
                void MarkOwnerDirty ()
362
350
                {
363
351
                        if (owner != null)
364
 
                                owner.MarkDirty (this);
 
352
                                owner.IsDirty = true;
365
353
                }
366
354
        }
367
355
}