none
Resource files fallback tracking RRS feed

  • Question

  • I have a large web site that has been converted to use resource files for different cultures. As the other languages are being added gradually the resource manager is successfully returning the base language text using the fall back process if the translation is missing. However I need to know when the text is not coming from the specified culture so I can log any missing translations.

    I’ve tried looking at GetResourceSet but I don’t seem to get anything back regardless of the parameters I set.

    Is there a way of determining which culture the ResourceManager returned or if it had to use the fallback processing?

    Friday, August 17, 2012 8:09 AM

Answers

  • Manage to solve it myself. The ResourceSet.GetString ignores the ResourceManagers IgnoreCase property and needs to be set for each call. I only spotted this when running an example to return all keys in the resource.

    'Get a ResourceSet in the current culture only

    runTimeResourceSet = Resource.GetResourceSet _(System.Globalization.CultureInfo.CurrentUICulture, True, False)

    'If the culture resource exist

    If Not runTimeResourceSet Is Nothing Then

    ReturnValue = runTimeResourceSet.GetString(“ResourceKey”, True)

           If Not String.IsNullOrEmpty(ReturnValue) Then

                  bFoundInCulture = True

    End If

    End If

    'Nothing found using the user's culture so, get the default culture and log the missing translation

    If not bFoundInCulture Then

    ReturnValue = Resource.GetString(val, DefaultCulture)

    'Log missing translation details

    End If

    • Proposed as answer by Adavesh Friday, August 17, 2012 9:55 AM
    • Marked as answer by Danny Kneale Friday, August 17, 2012 10:02 AM
    Friday, August 17, 2012 9:34 AM

All replies

  • Manage to solve it myself. The ResourceSet.GetString ignores the ResourceManagers IgnoreCase property and needs to be set for each call. I only spotted this when running an example to return all keys in the resource.

    'Get a ResourceSet in the current culture only

    runTimeResourceSet = Resource.GetResourceSet _(System.Globalization.CultureInfo.CurrentUICulture, True, False)

    'If the culture resource exist

    If Not runTimeResourceSet Is Nothing Then

    ReturnValue = runTimeResourceSet.GetString(“ResourceKey”, True)

           If Not String.IsNullOrEmpty(ReturnValue) Then

                  bFoundInCulture = True

    End If

    End If

    'Nothing found using the user's culture so, get the default culture and log the missing translation

    If not bFoundInCulture Then

    ReturnValue = Resource.GetString(val, DefaultCulture)

    'Log missing translation details

    End If

    • Proposed as answer by Adavesh Friday, August 17, 2012 9:55 AM
    • Marked as answer by Danny Kneale Friday, August 17, 2012 10:02 AM
    Friday, August 17, 2012 9:34 AM
  • Hi Danny,

    Thanks.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, August 20, 2012 3:10 AM
    Moderator