-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Runtime translation decisions. Not final.
- Loading branch information
Showing
10 changed files
with
202 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
FunctionZero.Maui.Controls/Services/Localisation/ExpressionString.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using FunctionZero.ExpressionParserZero.BackingStore; | ||
using FunctionZero.ExpressionParserZero.Evaluator; | ||
|
||
namespace FunctionZero.Maui.Services.Localisation | ||
{ | ||
public class ExpressionString | ||
{ | ||
private ExpressionTree _expression; | ||
private readonly string _resultString; | ||
|
||
public ExpressionString(ExpressionTree expression, string resultString) | ||
{ | ||
_expression = expression; | ||
_resultString = resultString; | ||
} | ||
|
||
public bool GetString(object backingStore, ref string result) | ||
{ | ||
result = _resultString; | ||
|
||
try | ||
{ | ||
if (backingStore is IBackingStore pocoBackingStore) | ||
return (bool)_expression.Evaluate(pocoBackingStore).Pop().GetValue(); | ||
else | ||
return (bool)_expression.Evaluate(new PocoBackingStore(backingStore)).Pop().GetValue(); | ||
} | ||
catch(Exception ex) | ||
{ | ||
result = ex.Message; | ||
return false; | ||
} | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...rols/Services/LanguageChangedEventArgs.cs → .../Localisation/LanguageChangedEventArgs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
FunctionZero.Maui.Controls/Services/Localisation/LanguageProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using FunctionZero.ExpressionParserZero.Binding; | ||
using FunctionZero.ExpressionParserZero.Evaluator; | ||
|
||
namespace FunctionZero.Maui.Services.Localisation | ||
{ | ||
public class LanguageProvider | ||
{ | ||
private readonly ExpressionTree _trueExpression; | ||
|
||
public LanguageProvider(Func<List<List<(ExpressionTree, string)>>> getLookup, string languageName) | ||
{ | ||
GetLookup = getLookup; | ||
LanguageName = languageName; | ||
} | ||
//item.Add((parser.Parse("true"), "There are loads of bananas!")); | ||
public LanguageProvider(Func<IEnumerable<string>> getLookup, string languageName) | ||
{ | ||
var parser = ExpressionParserFactory.GetExpressionParser(); | ||
_trueExpression = parser.Parse("true"); | ||
|
||
GetLookup = GetLookupFromStringList(getLookup); | ||
LanguageName = languageName; | ||
} | ||
|
||
private Func<List<List<(ExpressionTree, string)>>> GetLookupFromStringList(Func<IEnumerable<string>> getLookup) | ||
{ | ||
List<List<(ExpressionTree, string)>> lookup = new List<List<(ExpressionTree, string)>>(); | ||
foreach (var theString in getLookup()) | ||
{ | ||
var item = new List<(ExpressionTree, string)>(); | ||
item.Add((_trueExpression, theString)); | ||
lookup.Add(item); | ||
} | ||
return () => lookup; | ||
} | ||
|
||
|
||
//public Func<string[]> GetLookup { get; } | ||
public Func<List<List<(ExpressionTree, string)>>> GetLookup { get; } | ||
public string LanguageName { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters