* For a ship's captain: The most common translation would be captaen (pronounced roughly cap-tan). This is a direct borrowing from the English word, and is widely understood.
* For a military captain: You might use ceannaire (pronounced roughly kayn-yer), which means "leader" and is a more general term. The specific rank would depend on the branch of military and the historical period. There isn't a direct equivalent for the military rank of captain in the way that "captaen" is for a ship's captain.
Therefore, captaen is suitable if you're talking about a ship captain, but ceannaire (or a more specific military rank if appropriate) would be better for a military captain.