0
我看過這個https://www.youtube.com/watch?v=oGeAYd3idBc,我能夠創建多語言應用程序,但我需要幫助。我試圖用法文和英文創建一個下拉框,而不是我現在看到的兩個列表項鍊接。有誰知道如何做到這一點? 這裏是我的控制器將鏈接更改爲C語言下拉列表
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Threading;
using System.Web;
using System.Web.Mvc;
namespace MultiLanguage.Controllers
{
public class LanguageController : Controller
{
// GET: Language
public ActionResult Index()
{
return View();
}
public ActionResult Change(String LanguageAbbrevation)
{
if(LanguageAbbrevation !=null)
{
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(LanguageAbbrevation);
Thread.CurrentThread.CurrentUICulture = new CultureInfo(LanguageAbbrevation);
}
HttpCookie cookie = new HttpCookie("Language");
cookie.Value = LanguageAbbrevation;
Response.Cookies.Add(cookie);
return View("Index");
}
} 這裏是我的看法
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<ul>
<li>@Html.ActionLink("English","Change","Language",new {LanguageAbbrevation = "en"}, null)</li>
<li>@Html.ActionLink("French", "Change", "Language", new {LanguageAbbrevation = "fr" }, null)</li>
<li>@DateTime.Now.ToString()</li>
</ul>