code: protected Locale ensureLocale(Locale locale) {
  
          // get the default locale for the resource
          List<Locale> locales = OpenCms.getLocaleManager().getDefaultLocales(getCms(), getParamResource());
          if (m_content != null) {
              if (!m_content.hasLocale(locale)) {
                  try {
  
                      // to copy anything we need at least one locale
                      if ((m_content.getLocales().size() > 0)) {
                          // required locale not available, check if an existing default locale should be copied as "template"
                          try {
                              // a list of possible default locales has been set as property, try to find a match
                              m_content.copyLocale(locales, locale);
  
                          } catch (CmsException e) {
                              m_content.addLocale(getCms(), locale);
                          }
  
                      } else {
                          m_content.addLocale(getCms(), locale);
                      }
  
                      writeContent();
                  } catch (CmsException e) {
                      LOG.error(e.getMessageContainer(), e);
                  }
              }
              if (!m_content.hasLocale(locale)) {
                  // value may have changed because of the copy operation
                  locale = m_content.getLocales().get(0);
              }
          }
          return locale;
      }
docs: Makes sure the requested locale node is present in the content document
  by either copying an existing locale node or creating an empty one.<p>
  
  @param locale the requested locale
  
  @return the locale