Force 4-digit-year in localized strings generated from `DateTimeFormatter.ofLocalized…` in java.time

There is no built-in method for what you want. However, you could apply following workaround: Locale locale = Locale.ENGLISH; String shortPattern = DateTimeFormatterBuilder.getLocalizedDateTimePattern( FormatStyle.SHORT, null, IsoChronology.INSTANCE, locale ); System.out.println(shortPattern); // M/d/yy if (shortPattern.contains(“yy”) && !shortPattern.contains(“yyy”)) { shortPattern = shortPattern.replace(“yy”, “yyyy”); } System.out.println(shortPattern); // M/d/yyyy DateTimeFormatter shortStyleFormatter = DateTimeFormatter.ofPattern(shortPattern, locale); LocalDate today = LocalDate.now(ZoneId.of(“America/Chicago”)); String output … Read more

How to translate (internationalize, localize) application?

GetText should be able to do, search for “extract” at http://dxgettext.po.dk/documentation/how-to If all you need is to translate GUI and maybe resourcestring in sources, and the inline string constants in Pascal sources are not needed for translation, then you can try Delphi built-in method. However forums say that ITE is buggy. But at least that … Read more

How to fetch string from resource to assign in WPF Resource section in xaml

I was able to do it in a program with: <TextBlock VerticalAlignment=”Center” Margin=”3″ Text=”{x:Static prop:Resources.OpenButton}” Visibility=”{Binding Source={x:Static prop:Settings.Default}, Path=ShowButtonText, Converter={StaticResource BoolToVis}}”></TextBlock> I also had to include the .Properties namespace in my xaml, like so: xmlns:prop=”clr-namespace:MyProjectNamespace.Properties” This allowed me to not only use the string resources I had defined for my project for globalization, but I … Read more

Localization with String interpolation in SwiftUI

Apparently, a LocalizedStringKey will automatically generate the localization key depending on the type of the values interpolated. For example, if you have the following Texts Text(“title key”) Text(“name key \(“Club”)”) Text(“count key \(8)”) Text(“price key \(6.25)”) Your Localizable.strings file should look like “title key” = “Sandwiches”; “name key %@” = “Name: %@”; “count key %lld” … Read more

Marking some XIB/Storyboard strings as not localizable

I add a note “DNL” to the “Comment for Localizer” field in the identity tab. Then, I run this command to automatically remove all of those elements from the XLIFF: xmlstarlet ed -d “//*[contains(text(), ‘Note = \”DNL\”‘)]/..” en.xliff > out.xliff Basically, it’s using xmlstarlet (which can be downloaded via homebrew) to find all elements that … Read more

MVC 4 ignores DefaultModelBinder.ResourceClassKey

This is not specific to ASP.NET MVC 4. It was the same in ASP.NET MVC 3. You cannot set the required message using DefaultModelBinder.ResourceClassKey, only the PropertyValueInvalid. One way to achieve what you are looking for is to define a custom RequiredAttributeAdapter: public class MyRequiredAttributeAdapter : RequiredAttributeAdapter { public MyRequiredAttributeAdapter( ModelMetadata metadata, ControllerContext context, RequiredAttribute … Read more

Laravel change locale not working

App::setLocale() is not persistent, and sets locale only for current request(runtime). You can achieve persistent in multiple ways (example of 2): Route::post(‘/locale’, function(){ session([‘my_locale’ => app(‘request’)->input(‘locale’)]); return redirect()->back(); }); This will set session key with lang value from request for current user. Next create a Middleware to set locale based on user session language <?php … Read more

How to replace numbers in body to Persian numbers?

You can use this method: (http://jsfiddle.net/A4NfG/1/) persian={0:’۰’,1:’۱’,2:’۲’,3:’۳’,4:’۴’,5:’۵’,6:’۶’,7:’۷’,8:’۸’,9:’۹’}; function traverse(el){ if(el.nodeType==3){ var list=el.data.match(/[0-9]/g); if(list!=null && list.length!=0){ for(var i=0;i<list.length;i++) el.data=el.data.replace(list[i],persian[list[i]]); } } for(var i=0;i<el.childNodes.length;i++){ traverse(el.childNodes[i]); } }