Click here to Skip to main content
6,595,854 members and growing! (17,379 online)
Email Password   helpLost your password?
General Programming » Localisation » Localization     Intermediate License: The Code Project Open License (CPOL)

Validate strings in Resx files for all languages

By nkrscorpio

A tool to validate localization strings in Resx files supporting multiple languages.
C# (C# 3.0), Windows, .NET (.NET 3.5), LINQ, Dev, QA, Design
Posted:23 Sep 2008
Views:7,858
Bookmarked:7 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
0 votes for this article

Introduction

The .NET framework provides support for language localization using resx files. This tool helps to cross check the resx files for various languages, in a GridView. The code is based on .NET 3.5.

Background

For localization using satellite assemblies, please refer to: .NET - Localization using Resource file.

Using the code

With this utility, the user can select multiple resx files and validate if keys exist in all languages. It highlights the errors visibly in red so that a developer can quickly fix the resx files. The utility itself is a couple of lines of code.. thanks to LINQ and .NET 3.5.

void ParseFiles(string[] fileNames)
{
    int marker = 1;
    
    foreach (string file in fileNames)
    {

        XElement xElement = XElement.Load(file);

        IEnumerable<XElement> data = 
            from text in xElement.Elements("data")
            select text;

        foreach (XElement node in data)
        {
            string key = node.FirstAttribute.Value;

            int value = dictionary.ContainsKey(key)? dictionary[key]:0;

            dictionary[key] = value | marker;
        }

        marker = marker << 1;
    }
}

Points of interest

The code uses LINQ, and really looks neat and clean for the purpose.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

nkrscorpio


Member

Occupation: Software Developer
Location: United States United States

Other popular Localisation articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 3 of 3 (Total in Forum: 3) (Refresh)FirstPrevNext
GeneralBest Localization Plug-in for Visual Studio. PinmemberAlexander Nesterenko22:45 17 Dec '08  
GeneralZeta Resource Editor ;-) PinsitebuilderUwe Keim21:54 23 Sep '08  
GeneralRe: Zeta Resource Editor ;-) Pinmembernkrscorpio8:16 24 Sep '08  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 23 Sep 2008
Editor: Smitha Vijayan
Copyright 2008 by nkrscorpio
Everything else Copyright © CodeProject, 1999-2009
Web22 | Advertise on the Code Project