共用方式為


建立本地化類別定義

建立在地化類別定義是一個三步驟的流程。 首先,撰寫定義類別的MOF程式碼,包括必須當地語系化的所有限定符。 這個源檔稱為「主要MOF」檔案,因為它包含定義類別的所有限定符和屬性。

接下來,使用 MOF編譯程式 來建立MOF檔案的語言中性與特定語言版本。 MOF 編譯程式會將基本類別描述放在新的MOF檔案中,並建立只包含必須當地語系化之屬性和限定符的MOF檔案當地語系化版本。 雖然MOF檔案的語言特定和語言中性版本可以具有相同的檔名,但您應該使用 .mfl 擴展名來指出檔案包含當地語系化的資訊。 如有必要,您可以將 .mfl 檔案本地化為其他地區設定。 將類別定義儲存在 CIM 存放庫中需要額外的步驟,必須使用 MOF 編譯器來編譯語言中性 MOF 文件和特定語言的 MOF 文件。

下列步驟說明如何建立及儲存本地化類別定義。

建立及儲存本地化類別定義

  1. 建立主要MOF檔案,以定義您想要本地化的類別。

    將此MOF程式代碼儲存在名為 Mastermof.mof 的檔案中。

    #pragma namespace("\\\\.\\root")
    
    instance of __Namespace
    {
        Name = "TEST" ;
    } ;
    
    #pragma namespace("\\\\.\\root\\TEST")
    
    [Description("Localized version of MyClass for American English") 
        : Amended, LOCALE(0x409)] 
    
    class myclass
    {
        [DisplayName("User Name") : Amended,
        Description("The Name property contains the name of the user") : 
        Amended, key]
         string Name;
    
        uint64 Value; // non-localized value field
    
          [DisplayName("Time Stamp") : Amended,
        Description("This property shows when the object was created") : 
        Amended] 
         uint64 Timestamp;
    };
    
  2. 編譯 MasterMOF.mof 檔案,以建立語言中性及特定語言版本的 MOF 檔案。

    在命令提示字元中輸入下列命令,以編譯 MasterMOF.mof 檔案。

    mofcomp -MOF:Lnmof.mof -MFL:Lsmof.mfl -Amendment:MS_409 Mastermof.mof

  3. 編譯語言中性 (Lnmof.mof) 和語言特定 (Lsmof.mfl) 檔案,並將類別資訊儲存在 CIM 存放庫中。

    在命令提示字元中輸入下列命令,以將類別資訊儲存在 CIM 存放庫中。

    Mofcomp Lnmof.mof

    Mofcomp Lsmof.mfl

    編譯這些檔案之後,在 root\test 命名空間中會有語言中性類別定義,以及 root\test\ms_409 命名空間中的當地語系化類別定義。 如需編譯本地化MOF檔案的詳細資訊,請參閱 編譯本地化MOF檔案