给定一个英文句子，请使用Python代码将其转换为Pig Latin语言。转换规则为将单词的第一个辅音字母移到单词的结尾，然后加上“ay”。如果单词以元音字母开头，则结尾添加“yay”。


"The quick brown fox jumps over the lazy dog."
```python
def pig_latin(sentence):
    
    vowels = ['a', 'e', 'i', 'o', 'u']
    words = sentence.split()
    
    # 检查单词是否以元音字母开始，并分别添加后缀
    def check_vowel(word):
        if word[0] in vowels:
            return word + 'yay'
        else:
            for index, letter in enumerate(word):
                if letter in vowels:
                    return word[index:] + word[:index] + 'ay'
    
    # 对每个单词进行转换
    transformed_words = [check_vowel(word.lower()) for word in words]
    
    # 将首字母大写的单词重置为首字母大写形式
    for i in range(len(words)):
        if words[i][0].isupper():
            transformed_words[i] = transformed_words[i].capitalize()
    
    # 重新组合为句子
    transformed_sentence = ' '.join(transformed_words)
    return transformed_sentence

# 测试
sentence = "The quick brown fox jumps over the lazy dog."
print(pig_latin(sentence)) # => 'Hetay uickqay rownbay oxfay umpsjay overyay hetay azylay ogday.'
```