vb.net中的全球化 [英] globalization in vb.net

查看:125
本文介绍了vb.net中的全球化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我在vb.net.net中拥有一个网站,我想为此全球化,在此页面中拥有一个网页Default.aspx,我从下拉菜单中选择了几种语言, dorpdown并单击按钮,将文本转换为所选语言.为达到此目的,我在.vb文件中编写代码,如下所示


hello all i have a website in vb.net.i want to make my website globalized for this i have a webpage Default.aspx in this page i take a dropdown in which there is several languages when i select the language from the dorpdown and clicking on the button the text are converted into the selected language.to acheive this i write the code in .vb file is as follows


Imports System.Resources
Imports System.Globalization
Imports System.Threading

Partial Class _Default
    Inherits System.Web.UI.Page
    Private Sub Page_Load(ByVal sender As System.Object, _
             ByVal e As System.EventArgs) Handles MyBase.Load

        ''Put user code to initialize the page here
        If Not Page.IsPostBack Then
            drpLanguages.Items.Add(New  _
              System.Web.UI.WebControls.ListItem("English", "en-NZ"))

            Dim sLang As String = "en-NZ"
            SetCulture(sLang)
        End If
    End Sub
    Private Sub SetCulture(ByVal sLang As String)
        Dim gStrings As String
        Thread.CurrentThread.CurrentUICulture = New CultureInfo(sLang)
        Thread.CurrentThread.CurrentCulture = _
                 CultureInfo.CreateSpecificCulture(sLang)
        p1.InnerHtml = gStrings.GetString("p1")
        btnlang.Text = gString.GetString("btnlang")

    End Sub
   
  
    Protected Sub btnlang_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnlang.Click
        Dim sLang As String = drpLanguages.SelectedItem.Value
        SetCulture(sLang)

    End Sub
End Class




并添加一个名为Webform1的.vb文件,其代码如下所示:




and also add a .vb file named as Webform1 and the code is as folows----

Imports Microsoft.VisualBasic
Imports System.Resources
Imports System.Globalization
Imports System.Threading


Public Class Webform1
    Protected gStrings As New  _
ResourceManager("SatelliteAssemblies.Default", _
GetType(Webform1).Assembly)
End Class



但是问题是当我达到这个年龄时,错误是
"未声明名称gStrings."

请帮我解决该问题.

我应该在page_load上进行初始化吗?

我制作了所有资源文件.

谢谢和问候
subiya ahsan



but the problem is when i run this age the error is
""name gStrings is not declare."

please help me out what should i do to overcome from this problem.

should i made and initialization on page_load .

i make all the resourse file.

thanks and regard
subiya ahsan

推荐答案

尝试一下

try this

protected override void InitializeCulture()
{
    culture = "fr-FR";
    UICulture = culture;
    Culture = culture;
    //OR This
    if (culture != "Auto")
    {
        System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo(culture);
        System.Threading.Thread.CurrentThread.CurrentCulture = ci;
        System.Threading.Thread.CurrentThread.CurrentUICulture = ci;
    }
    base.InitializeCulture();
}


直接使用ResourceManager为btnlang和p1控件分配值.
use ResourceManager Directly to assign values to btnlang and p1 controls.


^ ]


这篇关于vb.net中的全球化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆