--------------------------------------------------------------------------------
--  State............ : Main
--  Author........... : 
--  Description...... : 
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
function PolyglotDemo.Main_onEnter ( )
--------------------------------------------------------------------------------
	
    local hUser = application.getCurrentUser ( )
    local dl = this.tDemoLanguages ( )
    local nIndex = this.nLanguageIndex ( )
    
    -- Create the HUD
    hud.newTemplateInstance ( hUser, "PolyglotHUD", "polyglotHUD" )
    
    -- localize the strings
    local count = hud.getComponentCount ( hUser )
    for i = 0, count - 1 do
        local comp = hud.getComponentAt ( hUser, i )
        local sComponentTag = hud.getComponentTag ( comp )
        local kType = hud.getComponentType ( comp )
        local sText = ""
        
        if kType == hud.kComponentTypeButton then
            sText = hud.getButtonText ( comp )
        elseif kType == hud.kComponentTypeLabel then
            sText = hud.getLabelText ( comp )
        elseif kType == hud.kComponentTypeCheck then
            sText = hud.getCheckText ( comp )
        elseif kType == hud.kComponentTypeEdit then
            sText = hud.getEditText ( comp )
        end
        
        user.sendEvent ( hUser, "polyglotLIB", "onTranslateHUD", sComponentTag, table.getAt ( dl, nIndex ), sText, false )
    end

--------------------------------------------------------------------------------
end
--------------------------------------------------------------------------------
