parent
5ec611d351
commit
752bdc92af
|
@ -1,12 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MyCommon
|
||||
{
|
||||
public class Class1
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
Key;Francais;English
|
||||
Hello;Bonjour;Hello
|
||||
MyName;Mon nom est paul;My name is paul
|
|
|
@ -0,0 +1,102 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace MyCommon
|
||||
{
|
||||
/// <summary>
|
||||
/// Manager MultiLang from .cvs file
|
||||
/// </summary>
|
||||
public class MultiLang
|
||||
{
|
||||
private Dictionary<string, List<string>> multiDictionary = new Dictionary<string, List<string>>(); //List of phrases by key
|
||||
private List<string> langs = new List<string>(); //Readable langs list
|
||||
|
||||
public int langsCount { get { return langs.Count; } }
|
||||
|
||||
/// <summary>
|
||||
/// Create Dictionary from string
|
||||
/// </summary>
|
||||
/// <param name="dico">Dictionary text</param>
|
||||
/// <see cref="Langs.cvs"/>
|
||||
public void Initialise(string dico)
|
||||
{
|
||||
multiDictionary.Clear();
|
||||
langs.Clear();
|
||||
string[] lines = dico.Split(new string[] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries); //Load from .cvs ressources.
|
||||
langs = lines[0].Split(';').OfType<string>().ToList();
|
||||
langs.RemoveAt(0);
|
||||
foreach (string line in lines)
|
||||
{
|
||||
List<string> items = line.Split(';').OfType<string>().ToList();
|
||||
string key = items[0];
|
||||
items.RemoveAt(0);
|
||||
multiDictionary.Add(key, items);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Language name from ID
|
||||
/// </summary>
|
||||
public string IDToLang(int lang)
|
||||
{
|
||||
if(lang < langs.Count)
|
||||
{
|
||||
return langs[lang];
|
||||
}
|
||||
else
|
||||
{
|
||||
return "!!!UNKNOW LANG KEY!!!";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Language ID form name
|
||||
/// </summary>
|
||||
public bool TryLangToID(string lang, out int ID)
|
||||
{
|
||||
for(int i = 0; i < langs.Count; i++)
|
||||
{
|
||||
if (lang == langs[i])
|
||||
{
|
||||
ID = i;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
ID = -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public List<string> GetWords(string key)
|
||||
{
|
||||
if (!multiDictionary.ContainsKey(key))
|
||||
return null;
|
||||
|
||||
return multiDictionary[key];
|
||||
}
|
||||
|
||||
public string GetWord(string key, int lang)
|
||||
{
|
||||
string text = "";
|
||||
|
||||
if (multiDictionary.ContainsKey(key))
|
||||
{
|
||||
if (multiDictionary[key].Count >= lang)
|
||||
{
|
||||
text = multiDictionary[key][lang];
|
||||
}
|
||||
else
|
||||
{
|
||||
text = "!!!UNKNOW LANG KEY!!!";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
text = "!!!UNKNOW WORD KEY!!!";
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,16 +1,17 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>276ceeb0-800f-4b90-aabc-d1b96dfc548b</ProjectGuid>
|
||||
<ProjectGuid>{276CEEB0-800F-4B90-AABC-D1B96DFC548B}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>MyCommon</RootNamespace>
|
||||
<AssemblyName>MyCommon</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
|
@ -30,25 +31,22 @@
|
|||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System"/>
|
||||
|
||||
<Reference Include="System.Core"/>
|
||||
<Reference Include="System.Xml.Linq"/>
|
||||
<Reference Include="System.Data.DataSetExtensions"/>
|
||||
|
||||
|
||||
<Reference Include="Microsoft.CSharp"/>
|
||||
|
||||
<Reference Include="System.Data"/>
|
||||
|
||||
<Reference Include="System.Net.Http"/>
|
||||
|
||||
<Reference Include="System.Xml"/>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Class1.cs" />
|
||||
<Compile Include="MultiLang.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Lang.csv" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
@ -57,5 +55,4 @@
|
|||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
|
||||
</Project>
|
||||
</Project>
|
|
@ -1,15 +1,14 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// Les informations générales relatives à un assembly dépendent de
|
||||
// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations
|
||||
// associées à un assembly.
|
||||
[assembly: AssemblyTitle("MyCommon")]
|
||||
[assembly: AssemblyProduct("MyCommon")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("MyCommon")]
|
||||
[assembly: AssemblyCompany("Sheychen")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2016")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
|
Loading…
Reference in New Issue