Source/NFX.Wave/Portal.cs
/// <summary>
/// Translates the named content into desired language trying to infer language from work context/locality/session.
/// The search is first done in this portal then in inherited portals.
/// Returns an empty string if no translation is possible
/// </summary>
Translates the named content into desired language trying to infer language from work context/locality/session.
The search is first done in this portal then in inherited portals.
Returns an empty string if no translation is possible
Translates the named content into desired language trying to infer language from work context / locality / session . The search is first done in this portal then in inherited portals . Returns an empty string if no translation is possible
public virtual string TranslateContent(string contentKey, string isoLang = null, WorkContext work = null)
      {
        if (isoLang.IsNullOrWhiteSpace())
          isoLang = GetLanguageISOCode(work);
        string result;
        var portal = this;
        while(portal!=null)
        {
          var content = portal.m_LocalizableContent;
          if (content.TryGetValue(contentKey+"_"+isoLang, out result)) return result;
          if (!isoLang.EqualsOrdIgnoreCase(portal.DefaultLanguageISOCode))
          {
            if (content.TryGetValue(contentKey+"_"+portal.DefaultLanguageISOCode, out result)) return result;
          }
          if (content.TryGetValue(contentKey, out result)) return result;
          portal = portal.Parent;
        }
        return string.Empty;
      }
public virtual string TranslateContent ( string contentKey , string isoLang = null , WorkContext work = null ) { if ( isoLang . IsNullOrWhiteSpace ( ) ) isoLang = GetLanguageISOCode ( work ) ; string result ; var portal = this ; while ( portal != null ) { var content = portal . m_LocalizableContent ; if ( content . TryGetValue ( contentKey + " " + isoLang , out result ) ) return result ; if ( ! isoLang . EqualsOrdIgnoreCase ( portal . DefaultLanguageISOCode ) ) { if ( content . TryGetValue ( contentKey + " " + portal . DefaultLanguageISOCode , out result ) ) return result ; } if ( content . TryGetValue ( contentKey , out result ) ) return result ; portal = portal . Parent ; } return string . Empty ; }
Translates the named content into desired language trying to infer language from work context/locality/session.
Translates the named content into desired language trying to infer language from work context / locality / session .
contentKey
string
isoLang
string
work
WorkContext