Adds translations for a specific language code.

@method add
@param {String} code Language code like sv_SE.
@param {Array} items Name/value array with English en_US to sv_SE.
161887
function (code, items) {
        var langData = data[code];

        if (!langData) {
          data[code] = langData = {};
        }

        for (var name in items) {
          langData[name] = items[name];
        }

        this.setCode(code);
      }
545772
private void initLanguageSwitch(Collection<Locale> locales, Locale current) {

        FormLayout languages = new FormLayout();
        languages.setHeight("100%");
        languages.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
        ComboBox languageSelect = new ComboBox();
        languageSelect.setCaption(m_messages.key(Messages.GUI_LANGUAGE_SWITCHER_LABEL_0));
        languageSelect.setNullSelectionAllowed(false);

        // set Locales
        for (Locale locale : locales) {
            languageSelect.addItem(locale);
            String caption = locale.getDisplayName(UI.getCurrent().getLocale());
            if (CmsLocaleManager.getDefaultLocale().equals(locale)) {
                caption += " ("
                    + Messages.get().getBundle(UI.getCurrent().getLocale()).key(Messages.GUI_DEFAULT_LOCALE_0)
                    + ")";
            }
            languageSelect.setItemCaption(locale, caption);
        }
        languageSelect.setValue(current);
        languageSelect.setNewItemsAllowed(false);
        languageSelect.setTextInputAllowed(false);
        languageSelect.addValueChangeListener(new ValueChangeListener() {

            private static final long serialVersionUID = 1L;

            public void valueChange(ValueChangeEvent event) {

                m_listener.handleLanguageChange((Locale)event.getProperty().getValue());

            }
        });

        if (locales.size() == 1) {
            languageSelect.setEnabled(false);
        }
        languages.addComponent(languageSelect);
        m_languageSwitch = languages;
    }
249352
public void addLocale(String locale) {

        m_searchObject.setLocale(locale);
        m_searchObjectChanged = true;
        ValueChangeEvent.fire(this, m_searchObject);
    }
411338
public TypedCode<TRANS> add(HttpCode<TRANS,?> code, String ... others) {
			StringBuilder sb = new StringBuilder();
			boolean first = true;
			for(String str : others) {
				if(first) {
					first = false; 
				} else {
					sb.append(',');
				}
				sb.append(str);
			}
			parse(code, sb.toString());
			
			return this;
		}
234473
function addLocale(context, payload) {
      context.commit({
        type: 'ADD_LOCALE',
        locale: payload.locale,
        translations: payload.translations
      });
    }
570167
def add_codedValue(self, name, code):
        
        if self._codedValues is None:
            self._codedValues = []
        self._codedValues.append(
            {"name": name, "code": code}
        )
285531
function _highlightBlockForLanguage(code, language, onComplete) {
        var patterns = _getPatternsForLanguage(language);
        _processCodeWithPatterns(_htmlEntities(code), patterns, onComplete);
    }
1278668
function (code) {
            var list = {}, cde = 'short', name = null;

            if ( typeof(code) != 'undefined' && typeof(userLocales[0][code]) == 'string' ) {
                cde = code
            } else if ( typeof(code) != 'undefined' ) (
                console.warn('`'+ code +'` not supported : sticking with `short` code')
            )

            for ( var i = 0, len = userLocales.length; i< len; ++i ) {

                if (userLocales[i][cde]) {

                    name = userLocales[i].full || userLocales[i].officialName.short;

                    if ( name )
                        list[ userLocales[i][cde] ] = name;
                }
            }

            return list
        }
303246
private function _loadLanguageItems()
    {
        $this->_languageItems = LanguageSource::find()
            ->joinWith(['languageTranslate' => function ($query) {
                $query->where(['language' => $this->_languageId]);
            },
            ])
            ->where(['category' => Scanner::CATEGORY_JAVASCRIPT])
            ->all();
    }
637280
function translate ($code)
    {
        if (preg_match_all("/<\?_\(\"(.*)\"\)\?>/siU", $code, $matches, PREG_SET_ORDER)) {
            foreach ($matches as $match) {
                if (isset($match[1])) {
                    $code = str_replace($match[0], gettext(stripslashes($match[1])), $code);
                }
            }
        }
        return $code;
    }
933594
private boolean replaceValues(Locale locale) {

        try {
            SortedProperties localization = getLocalization(locale);
            if (hasDescriptor()) {
                for (Object itemId : m_container.getItemIds()) {
                    Item item = m_container.getItem(itemId);
                    String key = item.getItemProperty(TableProperty.KEY).getValue().toString();
                    Object value = localization.get(key);
                    item.getItemProperty(TableProperty.TRANSLATION).setValue(null == value ? "" : value);
                }
            } else {
                m_container.removeAllItems();
                Set<Object> keyset = m_keyset.getKeySet();
                for (Object key : keyset) {
                    Object itemId = m_container.addItem();
                    Item item = m_container.getItem(itemId);
                    item.getItemProperty(TableProperty.KEY).setValue(key);
                    Object value = localization.get(key);
                    item.getItemProperty(TableProperty.TRANSLATION).setValue(null == value ? "" : value);
                }
                if (m_container.getItemIds().isEmpty()) {
                    m_container.addItem();
                }
            }
            return true;
        } catch (IOException | CmsException e) {
            // The problem should typically be a problem with locking or reading the file containing the translation.
            // This should be reported in the editor, if false is returned here.
            return false;
        }
    }
305728
def _add_locale(locale, strings)
      `t = document.createElement('template');
      document.body.appendChild(t);
      t.classList.add('i18n');
      t.setAttribute('data-lang', #{locale})`

      strings.each do |k, v|
        `e=document.createElement('p');
        t.content.appendChild(e);
        e.id=#{k.gsub('.', '-')};
        e.textContent=#{v}`
      end
    end
1122711
function (translationKey, translationDefaultValue) {
            if (regexName !== "JavascriptServiceArraySimpleQuote" &&
              regexName !== "JavascriptServiceArrayDoubleQuote") {
              if (keyAsText === true && translationDefaultValue.length === 0) {
                results[translationKey] = translationKey;
              } else {
                results[translationKey] = translationDefaultValue;
              }
            }
          }
1015679
function getLanguageCode(langCode) {
        if (!languageCodes[langCode]) {
            languageCodes[langCode] = langCode.split(/\-|_/).shift();
        }
        return languageCodes[langCode];
    }
980647
function translateInLanguageFilter(key, locale) {
    for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
      args[_key - 2] = arguments[_key];
    }

    return translateInLanguage.apply(void 0, [locale, key].concat(args));
  }
1185035
function (name, languages) {
        var language = AddOnManager.language;

        if (language && AddOnManager.languageLoad !== false) {
          if (languages) {
            languages = ',' + languages + ',';

            // Load short form sv.js or long form sv_SE.js
            if (languages.indexOf(',' + language.substr(0, 2) + ',') != -1) {
              language = language.substr(0, 2);
            } else if (languages.indexOf(',' + language + ',') == -1) {
              return;
            }
          }

          ScriptLoader.ScriptLoader.add(this.urls[name] + '/langs/' + language + '.js');
        }
      }
87264
function(items)
	{
		var register = [];

		/// Export as module if running under nodejs
		if (typeof global === 'object') {
			register.push(global);
		}

		if (typeof window === 'object') {
			register.push(window);
		}

		// Browse all resolved global objects and bind pwf items
		for (var i = 0; i < register.length; i++) {
			var obj = register[i];

			// Bind all requested items as global
			for (var key in items) {
				if (!items.hasOwnProperty(key)) {
					continue;
				}

				obj[key] = items[key];
			}

			// Check for all callbacks bound to this global object and call them
			if (typeof obj.on_pwf !== 'undefined') {
				var calls = obj.on_pwf;

				// Expecting list/array
				if (!(calls instanceof Array)) {
					calls = [calls];
				}

				for (var j = 0; j < calls.length; j++) {
					if (typeof calls[j] !== 'function') {
						throw new Error('on_pwf:not-a-method:' + j);
					}

					calls[j].apply(obj.pwf);
				}
			}
		}
	}