Replies: 6 comments 12 replies
-
Theres an ongoing discussion to support The main goal of TypealizR was to generate accessors over those untyped strings. But I´m open for improvments or alternate ways to achieve something similar utilizing some other "storage". I´d suggest that you might outline something (in pseudo-code). Examples would be a From there on, we could ellaborate a possible solution. |
Beta Was this translation helpful? Give feedback.
-
btw, if your on Windows, you might as well have a look at |
Beta Was this translation helpful? Give feedback.
-
btw, adopting another storage-mechanism would probably best be done by implementing some custom type which implements But I'm really open for exploring this topic to further drive the whole So if you've find the time, I'll be thankful for your thoughts and'll be glad to help ✌️. |
Beta Was this translation helpful? Give feedback.
-
I'm really looking for a way to future write localization for my self, so I do not have "answer" here. I see two school of managing translation strings - first is just write strings in English and let other translate things, second is to have unique codes which represent phrase. My understanding that this library and you is in the first camp. I would not try to preset one way as better then others, as market show both has their cases. Personally I'm in second camp, so that definitely affect how I thought about process. Also I think ResX is not very well suited for translation, and PO/XLIFF is much better alternative. I would use XLIFF as example here, but I think same can be applied. As developer I would like to have XLIFF files in the project files instead of ResX files, and let some tool generate typed access to the stings. I see this library as thin layer over translation mechainsm. Translation mechanism used then consult storage layer where he actually read underlying strings. Let's say we have translation mechanism based on Source XLIFF// Website.xliff
<trans-unit id="HomePageHeader" datatype="plaintext">
<source>Checkout TypealizR and make you localization better!</source>
<note>Header on the main website page</note>
</trans-unit>
<trans-unit id="HomePageHeaderLine2" datatype="plaintext">
<source>Unlock unparalleled development speed for quality translation!</source>
</trans-unit> or XLIFF 2.0 // Website.xliff
<unit id="HomePageHeader">
<notes>
<note category="instruction" id="n1">The translation should be formal</note>
<note category="comment" id="n2">Header on the main website page</note>
</notes>
<segment>
<source>Checkout TypealizR and make you localization better!</source>
</segment>
</unit>
<unit id="HomePageHeaderLine2">
<segment>
<source>Unlock unparalleled development speed for quality translation!</source>
</segment>
</unit> Generated code// TypealizR code
internal class WebsiteLocalization {
protected Microsoft.Extensions.Localization.IStringLocalizer Localize { get; }
public Greet_LoverExtensions (Microsoft.Extensions.Localization.IStringLocalizer localize)
{
this.Localize = localize;
}
/// <summary>
/// Header on the main website page
/// Returns string which translates "Checkout TypealizR and make you localization better!"
/// </summary>
public LocalizedString CheckoutTypealizRAndMakeYouLocalizationBetterLocalizedString() => Localize["HomePageHeader"];
/// <summary>
/// Header on the main website page
/// Returns string which translates "Checkout TypealizR and make you localization better!"
/// </summary>
public string CheckoutTypealizRAndMakeYouLocalizationBetter() => CheckoutTypealizRAndMakeYouLocalizationBetterLocalizedString().Value;
/// <summary>
/// Returns string which translates "Unlock unparalleled development speed for quality translation!"
/// </summary>
public LocalizedString UnlockUnparalleledDevelopmentSpeedForQualityTranslationLocalizedString() => Localize["HomePageHeaderLine2"];
/// <summary>
/// Returns string which translates "Unlock unparalleled development speed for quality translation!"
/// </summary>
public string UnlockUnparalleledDevelopmentSpeedForQualityTranslation() => UnlockUnparallelledDevelopmentSpeedForQualityTranslationLocalizedString().Value;
} Storage and translation mechanismAt this point TypealizR should not care who provide Other point which I think important for me, is to have function names generated not from source string, but from string identifier. // TypealizR code
internal class WebsiteLocalization {
protected Microsoft.Extensions.Localization.IStringLocalizer Localize { get; }
public Greet_LoverExtensions (Microsoft.Extensions.Localization.IStringLocalizer localize)
{
this.Localize = localize;
}
/// <summary>
/// Header on the main website page
/// Returns string which translates "Checkout TypealizR and make you localization better!"
/// </summary>
public LocalizedString HomePageHeaderLocalizedString() => Localize["HomePageHeader"];
/// <summary>
/// Header on the main website page
/// Returns string which translates "Checkout TypealizR and make you localization better!"
/// </summary>
public string HomePageHeader() => HomePageHeaderLocalizedString().Value;
/// <summary>
/// Returns string which translates "Unlock unparalleled development speed for quality translation!"
/// </summary>
public LocalizedString HomePageHeaderLine2LocalizedString() => Localize["HomePageHeaderLine2"];
/// <summary>
/// Returns string which translates "Unlock unparalleled development speed for quality translation!"
/// </summary>
public string HomePageHeaderLine2() => HomePageHeaderLine2LocalizedString().Value;
} Advanced features should be ignored initially, just taked into account during design, but not implemented, otherwise it would be hard to agree on things IMO. Content of translated strings should have format of library which will perform actual reading/translation. TypealizR should ignore it. Content of source string should have either TypealizR or format of library which perform actual reading/translation. For example maybe it would be wise teach TypealizeR about |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
@kant2002 Had some thoughts about implementing things here. One thing I really cannot wrap my head around is the fact that I mostly wonder where you´d plan to get such files from, in the first place. Surely not willing to write those by hand, aren´t you? |
Beta Was this translation helpful? Give feedback.
-
Approach which you show is invaluable for translation efforts. Do you consider having store data in mo or maybe have source gen over Xliff. Microsoft introduce in Net 7 NativeAOT and that scenario works not very well with Assembly resources, so I thinking about some other ways of storing/managing resources. Does that align with goals of this project?
Beta Was this translation helpful? Give feedback.
All reactions