.NET Framework - Collect strings for localication
Asked By Andrus
14-Feb-08 01:19 PM
I have a lot of localizable strings enclosed in double quotes in cs source
files.
I'm looking for a tool which extracts all those strings for localizaton to a
single file.
Or even better, it should generate resource file and replace all string
constants with localizable calls like
ResourceManager.GetString( Resources.MyString )
Any idea ?
Andrus.
ResourceManager
(1)
GetString
(1)
Collect
(1)
Localizable
(1)
Localizaton
(1)
Constants
(1)
Extracts
(1)
Day
(1)
Fredo replied...

It's much better to do this kind of thing by hand. Here are just a few
reasons why you don't want an automated tool for it:
Usually string replacements are done with some sort of name/value system.
You provide a name constant for the string which is then used in the code
via ResourceManager.GetString() or some other system. What names should be
given to the name constants? No automated tools is going to be able to come
up with something that really makes sense. It'll likely just come up with
STRING1, STRING2, STRING3, etc, or something along those lines.
Let's say your code does a lot of string output and in various places you
have the strings "\n" or "\r\n". Does the tool create a single resource for
all occurances of identical strings or does it create a different one for
each occurance? That will likely depend on what makes sense in a given
situation.
Some strings you don't want to replace. For example, you might not want to
replace the aforementioned "\n" and "\r\n" text.
Oftentimes strings are used internally and are never displayed to the user.
These strings don't need to (and often shouldn't, for performance reasons)
be replaced by some sort of string lookup.
These are just a few of the reasons why this should be done by hand, as
tedious as it is.
Additionally, it's always harder going back and trying to localize an app.
If there's a good chance your app is going to get localized, it ALWAYS pays
to do it up-front. I work on a fairly large project that's localized into 12
languages and we knew from day 1 it would be localized. It was still a pain
in the butt, but it would have been FAR more difficult if we hadn't planned
it from the beginning.

System.CodeDom.Compiler.GeneratedCodeAttribute (1) System.Diagnostics.DebuggerNonUserCodeAttribute (1) System.ComponentModel.EditorBrowsableAttribute (1) System.Resources.ResourceManager (1) System.Globalization.CultureInfo (1) Visual Studio (1) Hello TS, It seems you get an Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class HealthService { private static global::System.Resources.ResourceManager resourceMan; private static global::System.Globalization.CultureInfo resourceCulture; [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", internal HealthService() { } / / / <summary> / / / Returns the cached ResourceManager instance used by this class. / / / < / summary> [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DSHS.CMBHS.Resources.HealthService", typeof(HealthService).Assembly); resourceMan = temp; } return resourceMan; } } / / / <summary> / / / Overrides the current up a localized string similar to Appointment Type. / / / < / summary> internal static string AppointmentType { get { return ResourceManager.GetString("AppointmentType", resourceCulture); } } / / / <summary> / / / Looks up a localized string similar to Billing Unit. / / / < / summary> internal
New CDO.Configuration Const sch = 3D "http: / / schemas.microsoft.com / cdo / configuration / " strRemite = 3D rsX.Collect("Clave") strServer = 3D rsX.Collect("Servidor") strNombreorigen = 3D rsX.Collect("Nombre") strMailorigen = 3D rsX.Collect("Correo") intPuerto = 3D rsX.Collect("Puerto") bolSsl = 3D rsX.Collect("Ssl") bolAut = 3D rsX.Collect("Autentificacion") strPass = 3D Crypto(rsX Collect("Password")) If bolSsl = 3D True Then intSsl = 3D 1 Else intSsl = 3D 0 End If
das er die eingebettete Resource nicht finden kann. _assy = Assembly.GetExecutingAssembly() rm = New System.Resources.ResourceManager(String.Format("{0}.{1}.{1}", _assy.GetName().Name, "Resources"), _assy) Dim ci As CultureInfo = New CultureInfo("en-GB") Return rm.GetString("Test", ci) In meiner Anwendung habe ich den Ordner Resources und darin die Datei Resources wie greife ich richtig auf die entspr. Resource zu ? VB.NET - German Discussions System.Resources.ResourceManager (1) GetManifestResourceStream (1) ChangeUICulture (1) GetExecutingAssembly (1) ResourceManager (1) String.Format (1) Hallo Stefan, mit einer solchen resx-Datei habe ich noch nicht _assy = Assembly.GetExecutingAssembly() muß _assy = [Assembly].GetExecutingAssembly() heißen. Die nächste Zeile rm = New System.Resources.ResourceManager(String.Format("{0}.{1}.{1}", _assy.GetName().Name, "Resources"), _assy) scheint auch einen Fehler zu wird. Also z.B. Test1.Resources.Resources. Es scheint, dass Dein Program eine Mischung aus ResourceManager und ChangeUI ist. Wenn Du Dir die ResourceManager-Klasse anschaust (im Index ungefiltert nach System.Resources.ResourceManager suchen), wirst Du folgenden Code finden: (http: / / msdn.microsoft.com / de-de / library / system.resources
umsetzen Könnt ihr mir helfen? Fred. VB.NET - German Discussions System.Drawing.Bitmap (1) ResourceManager (1) VB (1) GetObject (1) GetString (1) Compiler (1) 2 Lösungen: * Direkt über den 'ResourceManager' gehen: 'My.Resources.ResourceManager'. * Reflection benutzen. - - M S Herfried K. Wagner M V P <URL:http: / / dotnet.mvps.org verzichten und direkt auf die Ressourcen per Key zugreifen: Dim lString As String = My.Resources.ResourceManager.GetString( _ My.Resources.Culture) Thorsten Dörfler - - Microsoft MVP Visual Basic vb-hellfire visual basic verständliche Antwort! So funktioniert es prima: Dim Bild As System.Drawing.Bitmap = My.Resources.ResourceManager.GetObject(zBez_Resource, My.Resources.Culture) Me.PB_grafik.Image = Bild . . . und wieder etwas dazugelernt (ResourceManager), Danke. Fred. Hallo Herfried, mit Hilfe des ResourceManager lies sich die Frage ja schnell lÃ
and where could I get good info. Thanks in advance. C# Discussions WindowsFormsApplication1.Resource1 (1) ResourceManager (1) Gregory.Thank (1) GetString (1) Repeat (1) GetType (1) Mulitilingual (1) Bustamante (1) Look up globalization / localization on the that you want to support. Access the resource from your code. Example: / / declare below private ResourceManager resourceManager; / / at your form constructor resourceManager = new ResourceManager("WindowsFormsApplication1.Resource1", GetType().Assembly); / / somewhere in your method / / create the label dynamically var label = new Label() Controls.Add(label); / / access the resource label.Text = resourceManager.GetString("String1"); Refer below MSDN site for details, http: / / msdn.microsoft.com / en-us / library / y99d1cd3