mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-08-01 16:30:28 +08:00
#18766: Implementing "cultures add" command
Work Item: 18766 --HG-- branch : 1.x
This commit is contained in:
parent
f1f52a9327
commit
a2a34101f3
@ -1,4 +1,5 @@
|
|||||||
using System.Linq;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using Orchard.Commands;
|
using Orchard.Commands;
|
||||||
using Orchard.Localization.Services;
|
using Orchard.Localization.Services;
|
||||||
|
|
||||||
@ -42,6 +43,23 @@ namespace Orchard.Localization.Commands {
|
|||||||
|
|
||||||
Context.Output.WriteLine(T("Site culture set to {0} successfully", cultureName));
|
Context.Output.WriteLine(T("Site culture set to {0} successfully", cultureName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[CommandHelp("cultures add <culture-name-1> ... <culture-name-n>\r\n\t" + "Add one or more cultures to the site")]
|
||||||
|
[CommandName("cultures add")]
|
||||||
|
public void AddCultures(params string[] cultureNames) {
|
||||||
|
IEnumerable<string> siteCultures = _cultureManager.ListCultures();
|
||||||
|
|
||||||
|
Context.Output.WriteLine(T("Adding site cultures {0}", string.Join(",", cultureNames)));
|
||||||
|
|
||||||
|
foreach (var cultureName in cultureNames.Distinct().Where(s => !siteCultures.Contains(s))) {
|
||||||
|
if (_cultureManager.IsValidCulture(cultureName)) {
|
||||||
|
_cultureManager.AddCulture(cultureName);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Context.Output.WriteLine(T("Supplied culture name {0} is not valid.", cultureName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user