Is there any way to automatically generate corresponding resx files for string localization in .NET?

StackOverflow https://stackoverflow.com/questions/2344897

  •  23-09-2019
  •  | 
  •  

문제

Using this answer, I created a sample localized app. My question is, is there some way to have Visual Studio automatically generated the strings.fr.resx file with the same strings (same names that is, with blank values), so someone who knows French can just fill them in, or do I actually have to manually create the resource for each language I want to support?

도움이 되었습니까?

해결책

You can do this with a 3rd party tool: Zeta Resource Editor

  1. Once you open Zeta Resource Editor (ZRE), you have to create a new ZRE project.
  2. Then you have to add your existing resource files into the this project.
    • To do this automatically for all resource files:
      1. Click on the "File Groups and tags" tab
      2. Click on "Automatically add multiple file groups to project" and follow the instructions.
  3. To add the new language:
    1. Highlight the appropriate node in the "Project files" tree.
    2. Click on the "File Groups and tags" tab
    3. Click on "Create new file" and follow the instructions.
    4. Make sure you include the newly created resex file into your Visual Studio project.

What's nice about using this tool is that you can also use it to export/import your translations to a spreadsheet for translations. (You can do this from the "Start" tab)


Alternatively, you could write your own small program to do this. The heart of the program is this:

using( ResXResourceReader reader = new ResXResourceReader( resourceFileName ) )
using( ResXResourceWriter writer = new ResXResourceWriter( newResourceFileName ) )
{
    foreach( DictionaryEntry entry in reader )
    {
        writer.AddResource( entry.Key.ToString(), "" );
    }

    writer.Generate();
    writer.Close();
}

다른 팁

private string GetPersonalSite(SPSite site)
{
    var curUser = SPContext.Current.Web.CurrentUser;
    SPServiceContext context = SPServiceContext.GetContext(site); 
    UserProfileManager upm = new UserProfileManager(context);
    UserProfile profile = upm.GetUserProfile(curUser.LoginName);
    return profile.PersonalUrl.AbsoluteUri;
}
.

작동해야합니다!동일한 consept가 SPServiceContext로 ServerContext를 변경했습니다.)

둘 다 동일한 Spsite 컨텍스트 복장을 갖습니다!

"Nofollow"> http://msdn.microsoft.com/en-us/library/ee546948.aspx

http://msdn.microsoft.com/en-us/도서관 / 사무실 / ms499329.aspx

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top