!
! Select a directory containing appropriate language versions of the
! return_*.txt files used to generate notification messages.
!
! The sample entries included below are ordered so that the following precedence
! is used in determining what language to use:
!   (1) Any message-specific preference expressed in an Accept-Language:,
!       Preferred-language:, or X-Accept-Language: header line.
!   (2) Any sending-user-specific preference stored in the directory in their
!       preferredLanguage attribute.
!   (3) Any sending-domain-specific preference (for domains in the directory)
!       stored in the domain's preferredLanguage attribute.
! Not taking effect since commented out are further entries that are examples
! of:
!   (4) Original-recipient-address-specific choices.
!   (5) Assumptions based on the top-level Internet domain of the sending user.
!
! The process for adding support for additional locales (languages) is:
!   (1) Create a directory 
!       <msg-instance>/imta/config/locale/<locale-name>/
!       and in it place the various language-appropriate versions of the
!       return_*.txt files.
!   (2) Add an entry (or entries) towards the top of the NOTIFICATION_MAPPING
!       table to support using that directory when the language is seen in 
!       a header line such as Accept-Language:.
!   (3) Add an entry for the language/locale to the LANGUAGE_LOCALES mapping
!       table to support using that directory when a preferredLanguage
!       attribute is seen for a sending user or domain. 
!
! Probes to this mapping table have the form:
! <dsn-type>|<source-channel>|<accept-language>|<return-address>|<1st-recip>
!
NOTIFICATION_LANGUAGE

!   Use any message-specific choice from Accept-Language:, Preferred-language:, 
! or X-Accept-Language: header line
!
  *|*|en*|*|*     $IIMTA_TABLE:locale/C/
  *|*|de*|*|*     $IIMTA_TABLE:locale/de/
  *|*|es*|*|*     $IIMTA_TABLE:locale/es/
  *|*|fr*|*|*     $IIMTA_TABLE:locale/fr/
  *|*|ja*|*|*     $IIMTA_TABLE:locale/ja/
  *|*|zh-TW|*|*   $IIMTA_TABLE:locale/zh_TW/
  *|*|zh*|*|*     $IIMTA_TABLE:locale/zh/
  *|*|ko*|*|*     $IIMTA_TABLE:locale/ko/
  *|*|pl*|*|*     $IMTA_TABLE:locale/pl/
!
! If a first language choice wasn't ok, check for additional language choices.
!
  *|*|$_*,$T**|*|*    $R$0|$1|$4|$5|$6
!
!   For one's "own" users -- those users in the LDAP directory -- check if the
! user (or failing that their domain) has a preferredLanguage set that 
! corresponds to a supported locale.  
!   The LDAP lookup is done from a subsidiary mapping table, 
! LDAP_USERS_LANGUAGE, rather than being coded directly here in the  
! NOTIFICATION_LANGUAGE mapping table since the use of a subsidiary table makes
! it more convenient to continue on with other sorts of probes, if desired, 
! if no relevant setting is found in the LDAP directory.
!   "Up level" searches on the domain name are disabled.  Various assumptions 
! regarding DIT layout and attribute usage are also incorporated in the
! LDAP_USERS_LANGUAGE mapping table; see the comments in that table for
! further details.
!   The LDAP_USERS_LANGUAGE mapping table also uses a subsidiary mapping
! table LANGUAGE_LOCALES, to determine which preferredLanguage values
! correspond to supported locales (and the directory name of the corresponding
! locale); if new locale support is added at a site, be sure to modify
! the LANGUAGE_LOCALES mapping table to add in the additional locales.
  *|*|*|*@*|*    $C$|LDAP_USERS_LANGUAGE;$3@$4|$E
!
!   For some "special" intended recipient (destination) addresses or domains, 
! one might wish to specially select the notification language, if the 
! original message sender had no explicit preference of their own.
! For instance, if english-list@siroe.com was such a special address,
! one could do: 
!
! *|*|*|*|english-list@siroe.com  $I$IMTA_TABLE:locale/C/
!
!   One could also choose to make assumptions based on the original sender's 
! domain, for instance as in the commented-out entries below.  (For a 
! performance improvement, one should change to instead use an entry that calls
! out to the general database to look up the 
! top-level-domain -> locale 
! correspondences, rather than having per top-level-domain entries.)
!
!  *|*|*|*.au|*     $IIMTA_TABLE:locale/C/
!  *|*|*|*.ca|*     $IIMTA_TABLE:locale/C/
!  *|*|*|*.gb|*     $IIMTA_TABLE:locale/C/
!  *|*|*|*.nz|*     $IIMTA_TABLE:locale/C/
!  *|*|*|*.uk|*     $IIMTA_TABLE:locale/C/
!  *|*|*|*.us|*     $IIMTA_TABLE:locale/C/
!  *|*|*|*.de|*     $IIMTA_TABLE:locale/de/
!  *|*|*|*.ar|*     $IIMTA_TABLE:locale/es/
!  *|*|*|*.bo|*     $IIMTA_TABLE:locale/es/
!  *|*|*|*.cl|*     $IIMTA_TABLE:locale/es/
!  *|*|*|*.co|*     $IIMTA_TABLE:locale/es/
!  *|*|*|*.cr|*     $IIMTA_TABLE:locale/es/
!  *|*|*|*.cu|*     $IIMTA_TABLE:locale/es/
!  *|*|*|*.ec|*     $IIMTA_TABLE:locale/es/
!  *|*|*|*.es|*     $IIMTA_TABLE:locale/es/
!  *|*|*|*.gp|*     $IIMTA_TABLE:locale/es/
!  *|*|*|*.gt|*     $IIMTA_TABLE:locale/es/
!  *|*|*|*.gy|*     $IIMTA_TABLE:locale/es/
!  *|*|*|*.mx|*     $IIMTA_TABLE:locale/es/
!  *|*|*|*.ni|*     $IIMTA_TABLE:locale/es/
!  *|*|*|*.pa|*     $IIMTA_TABLE:locale/es/
!  *|*|*|*.ve|*     $IIMTA_TABLE:locale/es/
!  *|*|*|*.fr|*     $IIMTA_TABLE:locale/fr/
!  *|*|*|*.fx|*     $IIMTA_TABLE:locale/fr/
!  *|*|*|*.pf|*     $IIMTA_TABLE:locale/fr/
!  *|*|*|*.tf|*     $IIMTA_TABLE:locale/fr/
!  *|*|*|*.jp|*     $IIMTA_TABLE:locale/ja/
!  *|*|*|*.tw|*     $IIMTA_TABLE:locale/zh_TW/
!  *|*|*|*.cn|*     $IIMTA_TABLE:locale/zh/
!  *|*|*|*.kp|*     $IMTA_TABLE:locale/ko/
!  *|*|*|*.kr|*     $IMTA_TABLE:locale/ko/
!  *|*|*|*.pl|*     $IMTA_TABLE:locale/pl/
!
! If no match is found, the default is to use the files from the 
! location specified by the IMTA_LANG option in the
! <server-instance>/imta/config/imta_tailor file.

!   LDAP_USERS_LANGUAGE is a subsidiary table that can be used by, for
! instance, the NOTIFICATION_LANGUAGE mapping table.  The probe for
! LDAP_USERS_LANGUAGE is expected to be an address or a domain name.
!   The table first checks whether the domain in the address is in the DC tree 
! (using the subsidiary DOMAIN_DC mapping table) and if the domain is in the 
! DC tree, then attempts to find a preferredLanguage attribute for a user in 
! the ORG tree with that address.  
!   If there is no such user or the user exists but has no preferredLanguage 
! setting, then the table checks whether the domain itself has a 
! preferredLanguage attribute set.
!   Any preferredLanguage value found is then checked against the list of 
! supported locales found in the LANGUAGE_LOCALES mapping table.
!   If all succeeds, return the string 
! IMTA_TABLE:/locale/<locale>/$I
!   Note that "up level" searches for the domain name are not performed.
! 
LDAP_USERS_LANGUAGE

! dc-ify the domain name.
  *@*  $C|DC|$0@$1|$|DOMAIN_DC;$1|
!
! We're now probing with |DC|<address>|<dc-ified-domain-name>
!
!   This following LDAP queries should use the site's service.dcroot (normally
! o=internet) as part of the dn for the query URL, and attempt to find the
! inetDomainBaseDN attribute in an inetDomain object, or find the
! aliasedObjectName attribute in an inetDomainAlias object.  Sites using a 
! different value for the configutil parameter service.dcroot should substitute
! their value where these queries use o=internet.  If a site uses attribute 
! names other than inetDomainBaseDN and aliasesObjectName for the equivalent 
! purposes, substitute appropriately.  These correspond to the 
! LDAP_DOMAIN_ATTR_BASEDN and LDAP_DOMAIN_ATTR_ALIAS option.dat options,
! respectively.  (The LDAP_DOMAIN_FILTER option.dat option, normally
! (|(objectClass=inetDomain)(objectclass=inetDomainAlias)), is more general
! than the two more specific filters shown here.)
!
  |DC|*@*|*  \
   $C|BDN|$0@$1|$2|$]ldap:///$2,o=internet?inetDomainBaseDN?sub?(objectClass=inetDomain)[
  |DC|*@*|*  \
   $C|BDN|$0@$1|$2|$]ldap:///$2,o=internet?aliasedObjectName?sub?(objectClass=inetDomainAlias))[
!
!   If we found the dc-ified domain in the DC tree, we're now probing with
! |BDN|<address>|<dc-ified-domain>|<basedn-in-org-tree>
!
!   Look for a setting for the particular mail user.
! Assuming ims50 schema, so looking for mail, mailAlternateAddress, 
! mailEquivalentAddress; for other schemas, substitute appropriate attributes
! (specifically, the attibutes specified by the LDAP_MAIL_ALIASES option.dat 
! value -- which defaults based on the LDAP_SCHEMATAG option.dat value).
!
  |BDN|*|*|*  \
   $C|LANG|$]ldap:///$2?preferredLanguage?sub?(|(mail=$0)(mailAlternateAddress=$0)(mailEquivalentAddress=$0))[
!
!   Didn't find that particular mail user, so now check for a domain-wide value
! Note that this ends up being essentially the same probe as the first ldap
! probe above, but since the mapping $]...[ substitution only preserves one
! returned attribute, it wouldn't have helped (other than perhaps performance
! via caching of lookups?) to have also asked for the preferredLanguage 
! attribute along with the inetDomainBaseDN attribute.
!
  |BDN|*|*|*  \
    $C|LANG|$]ldap:///$1,o=internet?preferredLanguage?sub?(|(objectClass=inetDomain)(objectClass=inetDomainAlias))[
!
  |LANG|*   $CIMTA_TABLE:locale/$|LANGUAGE_LOCALES;$0|/$$I$Y$E 
!
! end of the LDAP_USERS_LANGUAGE mapping table -- if we haven't had a success
! the mapping table doesn't set the $Y flag.

! This is a subsidiary mapping table used by the LDAP_USERS_LANGUAGE mapping
! table to turn a domain name into its dc components equivalent.
DOMAIN_DC

  *.           $N
  .*           $N
  *|DC|$_*.*   $R$0dc=$1,|DC|$2  
  *|DC|*       $0dc=$1$Y$E
  $_*.*        $Rdc=$0,|DC|$1
  *            dc=$0$Y$E

! This is a subsidiary mapping table used by the LDAP_USERS_LANGUAGE mapping
! table to convert any preferredLanguage value found in the LDAP directory into
! a valid locale name.  If new locales are added, they should be added to
! this table.
LANGUAGE_LOCALES

  en     C$Y
  de     de$Y
  es     es$Y
  fr     fr$Y
  ja     ja$Y
  zh-TW  zh_TW$Y
  zh     zh$Y
  ko     ko$Y
  pl     pl$Y
  *      $N

