How did Threepio understand the Ewoks?

This came up in a recent discussion and I thought I'd throw it out there and see what people think.In ROTJ,Threepio tells Luke that he's not sure what the Ewoks were saying,yet he still seems to be able to understand and communicate with them(at least on a basic level),which raises some questions.

My knowledge about the inner-workings of protocol droids and their programming is zilch,but it seems obvious enough that in order to understand the Ewok language,it would have to be programmed into Threepio's memory.Since he was not sure what they were saying,should we assume that it was not?Maybe the Ewok language was never known to anyone outside of Endor.If that's the case,maybe his CPU also acts as a learning computer,i.e.,he can learn and assimilate unfamiliar languages fairly quickly just by hearing it spoken.Again,I don't know much about droid programming.

Another idea is that it may not have been the core language itself that gave him problems.He did tell Luke they were using a 'very primitive dialect',and he says something similar in ESB when trying to communicate with Han's ship.One guess is that he's programmed to understand a given language,but the various dialects can confuse him.In other words,Threepio could speak English,but if he were talking to someone from say,New England or the Deep South,he may have problems with some of the nuances and speech patterns indigenous to those areas,or even older forms of English(i.e.,Victorian)for that matter.

I would have to guess he is some type of learning computer or has a learning brain. He is fluent in over 6 million forms of communication but as you said if no one has ever been on the planet before or heard the Ewoks speak how could the language be programmed into his computer.
Even though they are not necessarily supposed to have emotions, I think 3PO was having "delusions of grandeur" once he found out they thought he was "some sort of god".

C3-PO was able to understand the ewoks because his "brain" can pick up on the 'code' within a language. The more of a language he hears, the more he understands. In VECTOR PRIME he put on the cognition hood of a downed Coralskipper and after listening to several sentances he was able to translate it into basic. C3-PO couldn't have had previous knowledge on the Yuuzhan Vong language because they are from another Galaxy.

I personally would relate it to going to a different country. I would consider myself very capable with the spanish language - and the first time I went to Italy, I quickly picked up most of the basic semantics of Italian.

If there was a language pre-programmed in 3P0 that was similar to the language of the Ewoks he may have been able to incorporate it while learning Ewokese.

2. 3PO having 6 million forms of communication probally campared what the ewoks were saying to every other langauge and found one similar, i.e. the difference between spanish spoken in mexico and the spanish spoken in Spain, and his processors filled in the blanks.