mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Replace TryGetValue
Signed-off-by: Florian Grabmeier <flo.grabmeier@gmail.com>
This commit is contained in:
parent
b2b9f7caa5
commit
04e551d8bf
1 changed files with 10 additions and 8 deletions
|
|
@ -84,21 +84,23 @@ namespace Flow.Launcher.Plugin.Sys
|
||||||
|
|
||||||
private string GetDynamicTitle(Query query, Result result)
|
private string GetDynamicTitle(Query query, Result result)
|
||||||
{
|
{
|
||||||
var pair = KeywordTitleMappings
|
if (!KeywordTitleMappings.TryGetValue(result.Title, out var translationKey))
|
||||||
.Where(kvp => kvp.Key == result.Title && kvp.Key != kvp.Value)
|
|
||||||
.FirstOrDefault();
|
|
||||||
|
|
||||||
if (pair.Equals(default))
|
|
||||||
{
|
{
|
||||||
Log.Error($"Dynamic Title not found for: {result.Title}");
|
Log.Error($"Dynamic Title not found for: {result.Title}");
|
||||||
return "Title Not Found";
|
return "Title Not Found";
|
||||||
}
|
}
|
||||||
|
|
||||||
var translatedTitle = context.API.GetTranslation(pair.Value);
|
var translatedTitle = context.API.GetTranslation(translationKey);
|
||||||
var englishTitleMatch = StringMatcher.FuzzySearch(query.Search, pair.Key);
|
|
||||||
|
if (result.Title == translatedTitle)
|
||||||
|
{
|
||||||
|
return result.Title;
|
||||||
|
}
|
||||||
|
|
||||||
|
var englishTitleMatch = StringMatcher.FuzzySearch(query.Search, result.Title);
|
||||||
var translatedTitleMatch = StringMatcher.FuzzySearch(query.Search, translatedTitle);
|
var translatedTitleMatch = StringMatcher.FuzzySearch(query.Search, translatedTitle);
|
||||||
|
|
||||||
return englishTitleMatch.Score >= translatedTitleMatch.Score ? pair.Key : translatedTitle;
|
return englishTitleMatch.Score >= translatedTitleMatch.Score ? result.Title : translatedTitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Init(PluginInitContext context)
|
public void Init(PluginInitContext context)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue