Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localized demo #485

Merged
merged 1 commit into from
Jul 29, 2019
Merged

Localized demo #485

merged 1 commit into from
Jul 29, 2019

Conversation

tkouba
Copy link
Contributor

@tkouba tkouba commented Jul 24, 2019

Demo for complete localization of command line help using resources.

@tkouba tkouba mentioned this pull request Jul 24, 2019
@moh-hassan
Copy link
Collaborator

Thanks @tkouba for this demo.
It helps in mastering localization use.
I tried it using 'cs' localization

ReadText.LocalizedDemo head --help

ReadText.Demo 0.0.0.0
Copyright (C) 1 author
POUZITI:
normální scénár:
ReadText.LocalizedDemo.exe head file.bin
specifikace poctu byte:
ReadText.LocalizedDemo.exe head --bytes 100 file.bin
potlacit sumár:
ReadText.LocalizedDemo.exe head -q file.bin
precíst více rádek:
ReadText.LocalizedDemo.exe head --lines 10 file.bin
ReadText.LocalizedDemo.exe head --lines=10 file.bin

-n, --lines (Default: 5) Pocet rádek zobrazenych od zacátku nebo
konce souboru.

-c, --bytes Pocet bytu zobrazenych od zacátku nebo konce souboru.

-q, --quiet Potlacit sumár.

--help Zobrazit tuto nápovedu.

--version Zobrazit informaci o verzi.

input file (pos. 0) Povinné. Jméno vstupního souboru.

Very nice :)

using System.Text;
using CommandLine;
using CommandLine.Text;

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

   using System.Globalization;
    using System.Threading;

{
// Set sentence builder to localizable
SentenceBuilder.Factory = () => new LocalizableSentenceBuilder();

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

       //Apply localization for 'cs'
        var culture = CultureInfo.CreateSpecificCulture("cs");
        Thread.CurrentThread.CurrentCulture = culture;
        Thread.CurrentThread.CurrentUICulture = culture;

@moh-hassan moh-hassan merged commit 16ca79c into commandlineparser:develop Jul 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants