This topic has not yet been rated - Rate this topic

Context.contentLanguage property (apps for Office)

apps for SharePoint

Published: February 26, 2013

Gets the locale (language) specified by the user for editing the document or item.

var myContentLang = Office.context.contentLanguage;

A string in the RFC 1766 Language tag format, such as en-US.

The contentLanguage setting reflects the Editing Language setting specified with File > Options > Language in the Office host application.

function sayHelloWithContentLanguage() {
    var myContentLanguage = Office.context.contentLanguage;
    switch (myContentLanguage) {
        case 'en-US':
            write('Hello!');
            break;
        case 'en-NZ':
            write('G\'day mate!');
            break;
    }
}
// Function that writes to a div with id='message' on the page.
function write(message){
    document.getElementById('message').innerText += message; 
}

Supported clients

Excel 2013, Excel Web App, Word 2013, Outlook 2013, Outlook Web App, Project 2013, and PowerPoint 2013

Library

Office.js

Namespace

Office

Did you find this helpful?
(1500 characters remaining)

Community Additions

ADD
© 2013 Microsoft. All rights reserved.