code: void ensureSingleLocale(CmsXmlContainerPage containerPage, CmsResource localeRes) throws CmsException {
  
          CmsObject cms = getCmsObject();
          Locale mainLocale = CmsLocaleManager.getMainLocale(cms, localeRes);
          OpenCms.getLocaleManager();
          Locale defaultLocale = CmsLocaleManager.getDefaultLocale();
          if (containerPage.hasLocale(mainLocale)) {
              removeAllLocalesExcept(containerPage, mainLocale);
              // remove other locales
          } else if (containerPage.hasLocale(defaultLocale)) {
              containerPage.copyLocale(defaultLocale, mainLocale);
              removeAllLocalesExcept(containerPage, mainLocale);
          } else if (containerPage.getLocales().size() > 0) {
              containerPage.copyLocale(containerPage.getLocales().get(0), mainLocale);
              removeAllLocalesExcept(containerPage, mainLocale);
          } else {
              containerPage.addLocale(cms, mainLocale);
          }
      }
docs: Removes unnecessary locales from a container page.<p>
  
  @param containerPage the container page which should be changed
  @param localeRes the resource used to determine the locale
  
  @throws CmsException if something goes wrong