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

Added IncludeSourceRevisionInInformationalVersion to SampleApp so Version doesn't get added garbage #117

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ bin/
packages/
/.vs/
build/nuget.exe
/src/ExtractXliff/Properties/launchSettings.json
/src/**/Properties/launchSettings.json
/src/*/gitversion.json
37 changes: 32 additions & 5 deletions src/SampleApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Windows.Forms;
using L10NSharp;
using SampleApp.Properties;
using static System.String;

namespace SampleApp
{
Expand All @@ -21,6 +23,31 @@ static void Main(string[] args)
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);

if (args.Any(a => a == "-i:permissive"))
LocalizationManager.StrictInitializationMode = false;

try
{
// If StrictInitializationMode (the default), this should now throw an
// InvalidOperationException, which we will catch and (for the purposes
// of this sample app) ignore.
MessageBox.Show(Format(
LocalizationManager.GetString("accessed.before.setting.up.lm",
"Localization is not yet set up, so this will always be in English. " +
"It should not cause anything bad to happen even if the current culture " +
"is some other variant of a localized language (e.g., es-MX). By the " +
"way, the current locale is {0}"),
System.Globalization.CultureInfo.CurrentCulture.IetfLanguageTag),
"FYI");
}
catch (InvalidOperationException ex)
{
if (LocalizationManager.StrictInitializationMode)
Trace.WriteLine($"Got expected {ex.GetType().FullName} exception: {ex.Message}");
else
throw;
}

SetUpLocalization(args.Any(a => a == "-m"), args.Any(a => a == "-tmx"));

LocalizationManager.SetUILanguage(Settings.Default.UserInterfaceLanguage, false);
Expand All @@ -32,20 +59,20 @@ static void Main(string[] args)
_localizationManager = null;
}

public static void SetUpLocalization(bool useAdditionalMethodInfo, bool useTmx)
private static void SetUpLocalization(bool useAdditionalMethodInfo, bool useTmx)
{
if (useTmx)
throw new NotSupportedException("TMX-based localization is no longer supported.");

//your installer should have a folder where you place the localization files you're shipping with the program
// Your installer should have a folder where you place the localization files you're shipping with the program
var directoryOfInstalledLocFiles = "../../LocalizationFilesFromInstaller";
Directory.CreateDirectory(directoryOfInstalledLocFiles);

try
{
//if this is your first time running the app, the library will query the OS for the
//the default language. If it doesn't have that, it puts up a dialog listing what
//it does have to offer.
// If this is your first time running the app, the library will query the OS for the
// default language. If it doesn't have that, it puts up a dialog listing what
// it does have to offer.

var theLanguageYouRememberedFromLastTime = Settings.Default.UserInterfaceLanguage;

Expand Down
1 change: 1 addition & 0 deletions src/SampleApp/SampleApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<RootNamespace>SampleApp</RootNamespace>
<AssemblyTitle>SampleApp</AssemblyTitle>
<IsPackable>false</IsPackable>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net461' Or '$(TargetFramework)' == 'net48' ">
<Reference Include="System.Windows.Forms" />
Expand Down
Loading